Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3.  
  4. using namespace std;
  5. class stozek {
  6. private:
  7.  
  8. float h;
  9. float r;
  10. float L;
  11. private:
  12. void Zwrot_L()
  13. {
  14. L = sqrt(h*h + r*r);
  15.  
  16. }
  17.  
  18.  
  19.  
  20. public:
  21. float Objetosc;
  22. float Polepc;
  23.  
  24.  
  25. stozek(float h, float r)
  26. {
  27. h = h;
  28. r = r;
  29. Zwrot_L();
  30. }
  31. stozek(float h_, float r_, float l_)
  32. {
  33. h = h_;
  34. r = r_;
  35. L = l_;
  36. }
  37.  
  38.  
  39.  
  40. float Ppc()
  41. {
  42. Polepc = ((3.14*(r*r)) + (3.14*r*L));
  43. return Polepc;
  44.  
  45. }
  46. float V()
  47. {
  48.  
  49. Objetosc = ((3.14*(r*r)*h) / 3);
  50. return Objetosc;
  51. }
  52.  
  53. float zwort_L()
  54. {
  55. return L;
  56. }
  57.  
  58. };
  59. int main() {
  60. float h_1, r_1;
  61. cout << "Podaj h i r" << endl;
  62. cin >> h_1 >> r_1;
  63. stozek s1(3, 4, 5);
  64. stozek s2(h_1, r_1);
  65.  
  66. cout << "V=" << s1.V() << endl;
  67. cout << "PPc=" << s1.Ppc() << endl;
  68. cout << "tworz=" << s1.zwort_L() << endl;
  69.  
  70.  
  71. cout << "V=" << s2.V() << endl;
  72. cout << "PPc=" << s2.Ppc() << endl;
  73. cout << "tworz=" << s2.zwort_L() << endl;
  74.  
  75.  
  76.  
  77. system("pause");
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement