linkedin facebook linkedin facebook nod32

C++ tilida chiziqli algoritmlarni dasturlash

Muallif: Mengliyev Shoydullo

Qo`shilgan sana: 2014-10-27

1. C++ tilida chiziqli algoritmlarni dasturlash

1.1-masala. A va B ikkita haqiqy sonlar berilgan. Ularning yig’indisi, ayirmasi va ko’paytmasini hisoblang.
Yechish. A va b sonlar  yig’indisini S, ayirmasini D,  ko’paytmasini K  bilan belgilasak, S=a+b, d=a-b, k=a*b  formulalar o’rinli bo’ladi.
C++ da dasturu:
#include<iostream.h>  

Int main()
{
float a,b,s,p;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
s=a+b;
p=a*b;
cout <<"s=" <<s;
cout<<"p=" <<p;
system("PAUSE");
return 0;

}

1.2-masala. Ikkita musbat son berilgan, bu sonlarning o’rta arifmetik va o’rta geometrik qiymatlarini aniqlang.

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

Int main()
{
float a,b,s,p;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
s=(a+b)/2;
p=sqrt(a*b);
cout <<"s=" <<s;
cout<<"p=" <<p;
system("PAUSE");
return 0;
}

1.3-masala. Tomonlari A va B ga teng to’g’ri to’rtburchakning  yuzi va peremetri hisoblansin.

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

Int main()
{
float a,b,s,p;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
s=a+b;
p=2*(a*b);
cout <<"s=" <<s;
cout<<"p=" <<p;
system("PAUSE");
return 0;
}

1.4-masala. R1, R2, R3 uchta qarshiliklar ketma-ket ulangan zanjirning qarshiligini aniqlang.

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

Int main()
{
float R1,R2,R3,R;
cout <<”R1=”;cin>>R1;
cout<<”R2=”;cin>>R2;
cout<<”R3=”;cin>>R3;
R=R1+R2+R3;
cout<<"R=" <<R;
system("PAUSE");
return 0;
}

1.5-masala. Massalari M1 va M2 (kg) ga teng, oralaridagi masofa R (m) ga teng bo’lgan ikkita jismning o’zaro tortilish kuchi F aniqlansin.

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

Int main()
{
float M1,M2,R,F;
float G=6.672E-11 
cout<<”M1=”;cin>>M1;
cout<<”M2=”;cin>>R2;
cout<<”R=”;cin>>R;
F=G*M1*M2/(R*R);
cout<<"F=" <<F;
system("PAUSE");
return 0;
}

1.6-masala. Teng tomonli uchburchakning tomoni A ga teng. Uchburchakning yuzini toping.

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

  Int main()
{
float a,s;
cout<<”a=”;cin>>a;
S=(sqrt(3))*a*a/4;
cout <<"S=" <<S;
system("PAUSE");
return 0;
}

1.7-masala. Koordinatalari X1,Y1 va X2, Y2 ga teng bo’lgan nuqtalari orasidagi masofani hisoblang.

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

Int main()
{
float x1,x2,y1,y2,d;
cout<<”x1=”;cin>>x1;
cout<<”x2=”;cin>>x2;
cout<<”y1=”;cin>>y1;
cout<<”y2=”;cin>>y2;
d=sqrt(sqr(x2-x1)+sqr(y2-y1));
cout <<"d=" <<d;
system("PAUSE");
return 0;
}

1.8-masala. Birinchi hadi A, ayirmasi D, hadlari soni N ga teng arifmetik progressiyaning hadlarining yig’indisini hisoblang.

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

 Int main()
{
float a1,d,n,S;
cout<<”a1=”;cin>>a1;
cout<<”d=”;cin>>d;
cout<<”n=”;cin>>n;
S=(2*a1+d*(n-1))/2*n;
cout <<"S=" <<S;
system("PAUSE");
return 0;
}

1.9-masala. Birinchi hadi B, maxraji Q va hadlari soni N ga teng geometrik progressiyaning hadlarining yig’indisini hisoblang.

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

Int main()
{
float B,q,n,S;
cout<<”B=”;cin>>B;
cout<<”q=”;cin>>q;
cout<<”n=”;cin>>n;
S=(B*(1-exp(N*ln(q))))/(1-q);
cout <<"S=" <<S;
system("PAUSE");
return 0;
}

1.10-masala. Uchta idishga suv solingan. Idishlardagi suvning temperaturasi T1, T2, T3 ga teng, hajmi V1, V2, V3 (l) ga teng. Idishlardagi suvni bitta idishga quyilsa, uning hajmi va temperaturasi qanday bo’ladi?

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

Int main()
{
float T1,T2,T3,T,V1,V2,V3,V;
cout<<”T1=”;cin>>T1;
cout<<”T2=”;cin>>T2;
cout<<”T3=”;cin>>T3;
cout<<”V1=”;cin>>V1;
cout<<”V2=”;cin>>V2;
cout<<”V3=”;cin>>V3;
T=(T1*V1+T2*V2+T3*V3)/(V1+V2+V3);
V=V1+V2+V3;
cout <<"T=" <<T;
cout<<"V=" <<V;
system("PAUSE");
return 0;
}

1691 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
счетчик посещений