Advertisement
chelsea8410

bGrupa

Apr 27th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <pravougliTrougao.h>
  3. #include <cstdlib>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. pravougliTrougao T1,T2;
  10. int a,b,c;
  11. cout<<"Program za racunanje O , P i c pravouglog trougla."<<endl;
  12. cout<<"*****************************************************\n"<<endl;
  13. cout<<"Unesite podatke o 1. pravouglom trouglu:"<<endl;
  14. cout<<"a->"; cin>>a;
  15. cout<<"b->"; cin>>b;
  16.  
  17. T1.setA(a);
  18. T1.setB(b);
  19. c=T1.hipotenuza();
  20. T1.setC(c);
  21.  
  22. cout<<"\n******************************************\n"<<endl;
  23.  
  24. cout<<"Unesite podatke o 2. pravouglom trouglu:"<<endl;
  25. cout<<"a->"; cin>>a;
  26. cout<<"b->"; cin>>b;
  27.  
  28. T2.setA(a);
  29. T2.setB(b);
  30. c=T2.hipotenuza();
  31. T2.setC(c);
  32. system("cls");
  33. cout<<"Uneseni podaci o 1. trouglu:"<<endl;
  34. cout<<"Stranica A="<<T1.getA()<<endl;
  35. cout<<"Stranica B="<<T1.getB()<<endl;
  36. cout<<"\nIzracunati podaci:"<<endl;
  37. cout<<"Stranica C="<<T1.getC()<<endl;
  38. cout<<"Obim trougla O="<<T1.obim()<<endl;
  39. cout<<"Povrsina trougla P="<<T1.povrsina()<<"\n"<<endl;
  40.  
  41. cout<<"\n******************************************\n"<<endl;
  42.  
  43. cout<<"Uneseni podaci o 2. trouglu:"<<endl;
  44. cout<<"Stranica A="<<T2.getA()<<endl;
  45. cout<<"Stranica B="<<T2.getB()<<endl;
  46. cout<<"\nIzracunati podaci:"<<endl;
  47. cout<<"Stranica C="<<T2.getC()<<endl;
  48. cout<<"Obim trougla O="<<T2.obim()<<endl;
  49. cout<<"Povrsina trougla P="<<T2.povrsina()<<"\n"<<endl;
  50.  
  51. system("pause");
  52. return EXIT_SUCCESS;
  53.  
  54. }
  55. ####################pravougliTrougao.h#####################
  56. #ifndef PRAVOUGLITROUGAO_H
  57. #define PRAVOUGLITROUGAO_H
  58.  
  59.  
  60. class pravougliTrougao
  61. {
  62. public:
  63. pravougliTrougao();
  64. virtual ~pravougliTrougao();
  65.  
  66. int obim();
  67. int povrsina();
  68. int hipotenuza();
  69.  
  70. void setA(int aa)
  71. {
  72. a=aa;
  73. }
  74. void setB(int bb)
  75. {
  76. b=bb;
  77. }
  78. void setC(int cc)
  79. {
  80. c=cc;
  81. }
  82.  
  83.  
  84. int getA()
  85. {
  86. return a;
  87. }
  88. int getB()
  89. {
  90. return b;
  91. }
  92. int getC()
  93. {
  94. return c;
  95. }
  96.  
  97. protected:
  98. private:
  99. int a,b,c;
  100. };
  101.  
  102. #endif // PRAVOUGLITROUGAO_H
  103. ##############################pravougliTrougao.cpp#################################
  104. #include "pravougliTrougao.h"
  105. #include <math.h>
  106. pravougliTrougao::pravougliTrougao()
  107. {
  108. //ctor
  109. }
  110.  
  111. pravougliTrougao::~pravougliTrougao()
  112. {
  113. //dtor
  114. }
  115.  
  116. int pravougliTrougao::obim()
  117. {
  118. return (a+b+c);
  119. }
  120.  
  121. int pravougliTrougao::povrsina()
  122. {
  123. return ((a*b)/2);
  124. }
  125.  
  126. int pravougliTrougao::hipotenuza()
  127. {
  128. return (sqrt((a*a)+(b*b)));
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement