linkedin facebook linkedin facebook nod32

C++ tilida Tarmoqlanuvchi algoritmlarni dasturlash

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2014-10-01

1. C++ tilida Tarmoqlanuvchi algoritmlarni dasturlash

2.1-masala. Ax2+Bx+C=0 kvadrat tenglamaning ildizlarini toping.

C++  da dasturu:
#include<math.h>
#include<iostream.h>                                                                                                      

Int main()
{
float a,b,c,d,x1,x2;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
cout<<”c=”;cin>>c;
d=b*b-4*a*c;
if (d<0)
cout<<("tenglamaning haqiqiy ildizlari yoq");
if (d>0)
x1=(-b-sqrt(d))/(2*a);
x2=(-b+sqrt(d))/(2*a);
cout <<"x1=" <<x1;
cout<<"x2=" <<x2;
if (d=0)
x1=-b/(2*a);
cout <<"x1=" <<x1;
system("PAUSE");
return 0; 
}
2.2-masala. Ikki butun musbat son M va N larning eng katta umumiy bo’luvchisi (EKUB) ni aniqlang.
C++da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
int m,n,x,y;
m=StrToInt(Edit1->Text);
n=StrToInt(Edit2->Text);
x=m;y=n;
A:
if (x=y)  goto B;
if (x>y)  x=x-y;
if (x<y) y=y-x;
goto A;
B: cout <<"x=" <<x;
system("PAUSE");
return 0;
}

2.3-masala. Ikkita X va Y sonlarning kattasini tanlash (EKT) dasturini tuzing.

C++  da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
int m,y,x;
cout<<”x=”;cin>>x;
cout<<”y=”;cin>>y;
if (x==y)
cout<<("Bu sonlar teng");
if (x>y)  m=x; cout <<"m=" <<m;
if (x<y) x1=-b/(2*a);
cout <<"x1=" <<x1;
system("PAUSE");
return 0;
}

2.4-masala. Raketa V (km/soat) tezlik bilan Yer ekvatoridagi nuqtadan Yerning Quyosh atrofidagi orbitasi bo’ylab uchiriladi. Raketani uchirish natijasi qanday bo’ladi?

C++ da dasturu:
#include<iostream.h>                                                                                                      

 Int main()
{
float a;
cout<<”a=”;cin>>a;
if a<7.9 cout <<" Raketa Yerga qaytib tushadi=" <<a;
if (a>=7.9) and (a<11.2)
cout <<"Raketa Yerning sun`iy yo`ldoshiga aylanadi =" <<a;
if (a>=11.2) and (a<16.7)
cout <<"Raketa Quyoshning sun`iy yo`ldoshiga aylanadi=" <<a;
if a>=16.7 cout<<"Raketa Galaktikaning sun`iy yo`ldoshiga aylanadi=" <<a;
system("PAUSE");
return 0;
}

2.5-masala. Agar kvadratning tomoni A, doiraning radiusi R ga teng bo’lsa, kvadrat va doiraning yuzlarini solishtirib kattasini aniqlang.

C++  da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
Float a,r,sk,sd;
cout<<”a=”;cin>>a;
cout<<”r=”;cin>>r;
sk=a*a;  sd=pi*r*r;
if sk>sd then
{  
cout <<"Kvadratning yuzi katta!";
}
else
{
if sk<sd then
{
cout <<" Doiraning yuzi katta!";
}
else
{
cout <<" Yuzlari teng!";
}
system("PAUSE");
return 0;
}

1921 marta o`qildi.

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений