Advertisement
Guest User

Untitled

a guest
May 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. //---------------------------------------------------------------------------
  2.  
  3. #include <vcl.h>
  4. #include <iostream>
  5. #pragma hdrstop
  6. using namespace std;
  7. //---------------------------------------------------------------------------
  8. class Rectangle1
  9. {
  10. public:
  11. double w; //øèðèíà
  12. double h; //âûñîòà
  13. Rectangle1(double _w, double _h)
  14. {
  15. w=_w;
  16. h=_h;
  17. }
  18. double S() //ïëîùàäü
  19. {
  20. return w*h;
  21. }
  22. double P() //ïåðèìåòð
  23. {
  24. return 2*w+2*h;
  25. }
  26. };
  27.  
  28. class Circle1
  29. {
  30. public:
  31. double r; //ðàäèóñ
  32. Circle1(double _r)
  33. {
  34. r=_r;
  35. }
  36. double S() //ïëîùàäü
  37. {
  38. return 3.1415*r*r;
  39. }
  40. double P() //ïåðèìåòð
  41. {
  42. return 2*3.1415*r;
  43. }
  44. };
  45.  
  46. int main(int argc, char* argv[])
  47. {
  48. Rectangle1 r;
  49. cout << "Vvedite w & h: ";
  50. cin >> r.w >> r.h;
  51. cout <<"S = " << r.S() << " P = " << r.P() << endl;
  52.  
  53. Circle1 c;
  54. cout << "Vvedite r: ";
  55. cin >> c.r;
  56. cout <<"S = " << c.S() << " P = " << c.P()<< endl;
  57.  
  58. getchar();
  59. getchar();
  60. return 0;
  61. }
  62. //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement