logo

Dasturlash asoslari fanidan tayyorlagan Laboratoriya

Загружено в:

08.08.2023

Скачано:

0

Размер:

3986.591796875 KB
Dasturlash asoslari  fanidan tayyorlagan  Laboratoriya ishi.
Masalalar:
Masala yechimlari:
1 6-misol.
Dastur kodi
#include <iostream>
using namespace std;
int main(){
 int a, b, c;
 cin>>a>>b>>c;
 if(a<b and b<c) cout<<2*a<<"  "<<2*b<<" "<<2*c;
 else cout<<a<<"  "<<b<<" "<<c;
}
Natija.
Agar a<b<c: 
Aks holda
7-misol.
2 Dastur kodi.
#include <iostream>
using namespace std;
int main()
{
 float a, b, c;
 cin>>a>>b>>c;
 if(a<b and b<c) cout<<2*a<<"  "<<2*b<<" "<<2*c;
 else if(a>b and b>c) cout<<2*a<<"  "<<2*b<<" "<<2*c;
 else cout<<a<<"  "<<b<<" "<<c;
}
Natija:
O’sish tartibida bo’lganda.
Kamayish tartibida bo’lganda.
3 O’sish yoki kamayish bo’lmagan hollarda.
8-misol.
4 Dastur kodi.
#include <iostream>
using namespace std;
int main()
{
 int a, b, c;
 cin>>a>>b>>c;
 if(a==b) cout<<3;
 if(a==c) cout<<2;
 if(b==c) cout<<1;
}
Natija:
14-misol.
5 Dastur kodi.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
 float x, y;
 cin>>x;
 if(x>0){  
  y=2*sin(x);
 }
 else y=x-6;
 cout<<y;
}
Natija:
15-
misol.
6 Dastur kodi.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
 float x, y;
 cin>>x;
 if(x<-2 or x>2){
    y=2*x;
 }
 else y=(-3)*x;
 cout<<y;
}
Natija:
7

Dasturlash asoslari fanidan tayyorlagan Laboratoriya ishi. Masalalar: Masala yechimlari: 1

6-misol. Dastur kodi #include <iostream> using namespace std; int main(){ int a, b, c; cin>>a>>b>>c; if(a<b and b<c) cout<<2*a<<" "<<2*b<<" "<<2*c; else cout<<a<<" "<<b<<" "<<c; } Natija. Agar a<b<c: Aks holda 7-misol. 2

Dastur kodi. #include <iostream> using namespace std; int main() { float a, b, c; cin>>a>>b>>c; if(a<b and b<c) cout<<2*a<<" "<<2*b<<" "<<2*c; else if(a>b and b>c) cout<<2*a<<" "<<2*b<<" "<<2*c; else cout<<a<<" "<<b<<" "<<c; } Natija: O’sish tartibida bo’lganda. Kamayish tartibida bo’lganda. 3

O’sish yoki kamayish bo’lmagan hollarda. 8-misol. 4

Dastur kodi. #include <iostream> using namespace std; int main() { int a, b, c; cin>>a>>b>>c; if(a==b) cout<<3; if(a==c) cout<<2; if(b==c) cout<<1; } Natija: 14-misol. 5