Advertisement
programusy

Untitled

Feb 16th, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class prostokat{
  6. private:
  7. double a;
  8. double b;
  9. friend void pole(prostokat p);
  10. friend void obwod(prostokat p);
  11. public:
  12. prostokat(double a_,double b_);
  13.  
  14.  
  15. };
  16.  
  17. prostokat::prostokat(double a_,double b_){
  18. a=a_;
  19. b=b_;
  20.  
  21.  
  22. }
  23.  
  24. void pole(prostokat p){
  25.  
  26. cout << p.a*p.b << endl;
  27.  
  28. }
  29.  
  30.  
  31. void obwod(prostokat p){
  32.  
  33. cout << p.a*2+p.b*2 << endl;
  34.  
  35. }
  36.  
  37. class trojkat{
  38. private:
  39. double a;
  40. double b;
  41. double c;
  42. double h;
  43. friend void pole(trojkat p);
  44. friend void obwod(trojkat p);
  45. public:
  46. trojkat(double a_,double b_, double c_, double h_);
  47. };
  48.  
  49. trojkat::trojkat(double a_,double b_, double c_, double h_){
  50. if(a<b+c){
  51. cout<< "to nie trojkat";
  52.  
  53. }
  54. else if(b<c+a){
  55. cout<< "to nie trojkat";
  56.  
  57. }
  58. else if(c<b+a){
  59. cout<< "to nie trojkat";
  60.  
  61. }
  62. else{
  63. a=a_;
  64. b=b_;
  65. c=c_;
  66. h=h_;
  67.  
  68. }
  69. }
  70. void pole(trojkat p){
  71.  
  72. cout << (p.h*p.a)/2<< endl;
  73.  
  74. }
  75.  
  76.  
  77. void obwod(trojkat p){
  78.  
  79. cout <<a+b+c << endl;
  80.  
  81. }
  82.  
  83. int main()
  84. {
  85. prostokat p1(10,2);
  86. pole(p1);
  87. cout << "Hello world!" << endl;
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement