Dasturlash asoslari fanidan tayyorlagan Laboratoriya
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