6-amaliy mashg’ulot yuzasidan topshiriqlar


Download 45.7 Kb.
Sana10.01.2022
Hajmi45.7 Kb.
#268956
Bog'liq
6-amaliy


6-amaliy mashg’ulot yuzasidan topshiriqlar

1-masala


Berilish: Og'irlik birliklari quyidagi tartibda berilgan. 1-kilogramm, 2-milligramm, 3-gramm, 4-tonna, 5-sentner. Og'irlik birligini bildiruvchi soni berilgan va shu birlikdagi og'irlik qiymati berilgan. Og'irlikni kilogramda ifodalovchi programma tuzilsin.

#include

using namespace std;

int main()

{int n; float m;

cout<<"Og'irlik birligini ifodalovchi son=";cin>>n;

cout<<"Massa=";cin>>m;

switch(n)

{

case 1:cout<

case 2:cout<

case 3:cout<

case 4:cout<

case 5:cout<

default: cout<<"xato raqam";

}


return 0;}



2-masala


Berilishi: Sanani bildiruvchi ikkita butun son berilgan D (kun) va M (oy). (Kabisa bo'lmagan yil sanasi kiritiladi). Berilgan sanani ifodalovchi programma tuzilsin. Kabisa yilida 366 kun, kabisa bo’lmagan yilda 365 kun bor bo’ladi.

#include

using namespace std;

int main()

{int d,m;

cout<<"Kun=";cin>>d;

cout<<"Oy=";cin>>m;

if(d>0&&m>0&&m<13&&d<32)

{if(m==2&&d>28)

cout<<"fevral 28 da tugaydi";

else switch(m)

{case 1:cout<

case 2:cout<

case 3:cout<

case 4:cout<

case 5:cout<

case 6:cout<

case 7:cout<

case 8:cout<

case 9:cout<

case 10:cout<

case 11:cout<

case 12:cout<

}}else cout<<"Bunday sana mavjud emas";



return 0;}





3-masala


Berilish: Ikkita butun son berilgan D (kun) va M (oy). (Kabisa bo'lmagan yil sanasi kiritiladi). Berilgan sanadan keyingi sanani ifodalovchi programma tuzilsin.

#include

using namespace std;

int main()

{int d,m;

cout<<"Kun=";cin>>d;

cout<<"Oy=";cin>>m;

if(d>0&&m>0&&m<13&&d<32)

{if(m==2&&d>28)

cout<<"fevral 28 da tugaydi";

else switch(m)

{case 1:(d==31)?cout<<"1-fevral":cout<

case 2:(d==28)?cout<<"1-mart":cout<

case 3:(d==31)?cout<<"1-aprel":cout<

case 4:(d==31)?cout<<"1-may":cout<

case 5:(d==31)?cout<<"1-iyun":cout<

case 6:(d==31)?cout<<"1-iyul":cout<

case 7:(d==31)?cout<<"1-avgust":cout<

case 8:(d==31)?cout<<"1-sentabr":cout<

case 9:(d==31)?cout<<"1-oktabr":cout<

case 10:(d==31)?cout<<"1-noyabr":cout<

case 11:(d==31)?cout<<"1-dekabr":cout<

case 12:(d==31)?cout<<"1-yanvar":cout<

}}else cout<<"Bunday sana mavjud emas";



return 0;}



4-masala


Berilishi: Robot faqat to'rtta tomonga ko'cha oladi(“s"-shimol, “j"-janub, "q"-sharq, "g"-g’arb) va uchta raqamli kamanda: 0-harakatni davom ettir, 1-chapga buril, 2-o'ngga buril. Y - robot yo'nalishi va K - kamanda berilgan. Berilgan komanda bajarilgandan keying robot holatini aniqlovchi programma tuzilsin.

#include

using namespace std;

int main()

{int b;char t;

cout<<"Y=";cin>>t;

switch (t)

{case 's':cout<<"shimol \n";break;

case 'j':cout<<"janub \n";break;

case 'q':cout<<"sharq \n";break;

case 'g':cout<<"g'arb \n";break;

default:cout<<"bunday yo'nalish yo'q \n";}

cout<<"K=";cin>>b;

switch(b)

{case 0:cout<<" harakatni davom ettir";break;

case 1:cout<<" chapga buril";break;

case 2:cout<<" o'nga buril";break;

default:cout<<"bunday buyruq yo'q";}



return 0;}



5-masala


Berilishi: Uzunlik birliklari quyidagi tartibda berilgan. 1-desimetr, 2-kilometr, 3-metr, 4-millimeter, 5-santimetr. Uzunlik birligini bildiruvchi son berilgan (1-5 oraliqda) va shu birlikdagi kesma uzunligi berilgan (haqiqiy son). Kesmaning uzunligini metrlarda ifodalovchi programma tuzilsin.

#include

using namespace std;

int main()

{int n;float m;

cout<<"Uzunlik=";cin>>m;

cout<<"Uzunlik birligini ifodalaovchi son=";cin>>n;

switch(n)

{

case 1:cout<

case 2:cout<

case 3:cout<

case 4:cout<

case 5:cout<

default:cout<<"Bunday birlik kiritilmagan";

}

return 0;}






Download 45.7 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling