Kacper-p

program obliczeniowy

Nov 15th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. //napisz program obliczający pole, obwod trojkonta kwadrat prostokont
  2. #include<iostream>
  3. #include<conio.h>
  4. #include<cstdlib>
  5. using namespace std;
  6. int a, b, c, h;
  7. char znak;
  8. int main()
  9. {
  10. cout<<"Podaj bok a: "; cin>>a;
  11. cout<<"Podaj bok b: "; cin>>b;
  12. cout<<"Podaj bok c: ";cin>>c;
  13. cout<<"Podaj wysokosc h: "; cin>>h;
  14. cout<<"Menu"<<endl;
  15. cout<<"----"<<endl;
  16. cout<<"1.Kwadrat"<<endl;
  17. cout<<"2.Prostokant"<<endl;
  18. cout<<"3.Trojkat"<<endl;
  19. znak=getch();
  20. switch(znak)
  21. {
  22. case'1' :
  23. cout<<"Pole: "<<a*a<<endl;
  24. cout<<"Obwod: "<<4*a<<endl;
  25. break;
  26. case '2' :
  27. cout<<"Pole: "<<a*b<<endl;
  28. cout<<"Obwod: "<<2*a+2*b<<endl;
  29. break;
  30. case '3' :
  31. cout<<"Pole: "<<a*h/2<<endl;
  32. cout<<"Obwod: "<<a+b+c<<endl;
  33. cout<<"Czy trojont jest prostokontny?"<<endl;
  34. if((a*a)+(b*b)==(c*c))
  35. {
  36. cout<<"Boki tworza trojant prostokatny";
  37. }
  38. else
  39. {
  40. cout<<"Boki nie tworza trojkonta";
  41. }
  42. break;
  43. default:
  44. cout<<"nieprawidlowe rzadanie!"<<endl;
  45. exit(0);
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment