3-kurs 302 ami programmalash asoslari fanidan 3-labaratoriya ishi


Download 136.29 Kb.
Sana23.02.2023
Hajmi136.29 Kb.
#1225579
Bog'liq
3-topshiriq


3-kurs 302 AMI Programmalash asoslari fanidan
3-labaratoriya ishi

13-savol: Tengyonli uchburchakning elementlari quyidagi tartibda nomerlangan: 1-katet a, 2-gipotenuza c=a*sqrt(2), 3- gipotenuzaga tushurilgan balantlik h­ (h=c/2), 4-yuzasi S=(c*h)/2. Shu elementlardan bittasi berilganda qolganlarini topuvchi dastur tuzing.


Javob:
#include
#include
using namespace std;
int main(){

double a,c,h,S;


char x;

cout<<"Qaysi o'zgaruvchini kiritasiz "<
cout<<" Katet a "<cout<<" Gipotenuza c "<cout<<" Balantlik h "<cout<<" Yuza S "<cin>>x;

/*
a= c/sqrt(2) = sqrt(2)*h= sqrt(2*S);


c= a*sqrt(2) = 2h = 2*sqrt(S);
h= c/2 = sqrt(S) = a/sqrt(2);
S= (c*h)/2 = pow(c,2)/4 = pow(h,2)= pow(a,2)/2;
*/
switch (x) {
case 'a': cout<<" a= "; cin>>a;
cout<<" c= "<cout<<" h= "<cout<<" S= "<
2)/2<break;
case 'c': cout<<" c= "; cin>>c;
cout<<" a= "<< c/sqrt(2)<cout<<" h= "<< c/2 <cout<<" S= "<
2)/4<break;
case 'h': cout<<" h= "; cin>>h;
cout<<" a= "<< sqrt(2)*h <cout<<" c= "<< 2*h <cout<<" S= "<< pow(h,2)<break;
case 'S': cout<<" S= "; cin>>S;
cout<<" a= "<cout<<" c= "<<2*sqrt(S)<cout<<" h= "<break;
default:cout<<"Noto'g'ri belgi!!!";
break;
}
return 0;
}



Download 136.29 Kb.

Do'stlaringiz bilan baham:




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