Advertisement
Guest User

Untitled

a guest
May 20th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 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.  
  49. string cmd;
  50.  
  51. cin >> cmd;
  52.  
  53. while (cmd != bye)
  54. {
  55. if (cmd == "rect")
  56. {
  57. Rectangle1 r(0,0);
  58. cout << "Vvedite w & h: ";
  59. cin >> r.w >> r.h;
  60. cout <<"S = " << r.S() << " P = " << r.P() << endl;
  61. }
  62. else if (cmd == "circ")
  63. {
  64. Circle1 c(0);
  65. cout << "Vvedite r: ";
  66. cin >> c.r;
  67. cout <<"S = " << c.S() << " P = " << c.P()<< endl;
  68. }
  69. else
  70. {
  71. cout << "ya ne ponyala!" << endl;
  72. }
  73. cin >> cmd;
  74.  
  75. }
  76.  
  77. getchar();
  78. getchar();
  79. return 0;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement