Advertisement
Guest User

krisan mare programator

a guest
Dec 13th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #include <iostream>
  2. #include<cmath>
  3.  
  4. using namespace std;
  5.  
  6. class Triunghi_echilateral;
  7. class Triunghi
  8. {
  9.  
  10. public:
  11. float a,b,c,p;
  12. void arieperimetru();
  13. void citire();
  14.  
  15. };
  16. void Triunghi::citire()
  17. {
  18. cout << " Dati laturile triunghiului : \n";
  19. cin>>a>>b>>c;
  20. cout<<"Lungimile laturilor A,B si C ale triunghiului sunt : \n " << a <<" "<< b <<" " << c <<" "<<"\n"<<endl;
  21. }
  22. void Triunghi::arieperimetru()
  23. {
  24. float aria, perimetrul;
  25. p=(a+b+c)/2;
  26. aria=sqrt(p*(p-a)*(p-b)*(p-c));
  27. perimetrul=a+b+c;
  28. cout<<"Aria triunghiului este : " << aria<<"\n"<<endl;
  29. cout<<"Perimetrul triunghiului este : " <<perimetrul<<"\n"<<endl;
  30. }
  31. class Triunghi_echilateral :public Triunghi
  32. {
  33. public:
  34. void verificaEC();
  35.  
  36. };
  37. class Triunghi_isoscel : public Triunghi_echilateral
  38. {
  39.  
  40. public:
  41. void verificaIS();
  42.  
  43. };
  44. void Triunghi_isoscel::verificaIS()
  45. {
  46. int k=0;
  47. if( (Triunghi::a==Triunghi::b&&Triunghi::a!=Triunghi::c) || (Triunghi::a==Triunghi::c&&Triunghi::a!=Triunghi::b) || (Triunghi::b==Triunghi::c&&Triunghi::b!=Triunghi::a) )
  48. k=1;
  49. if(k)
  50. cout<<"Triunghiul este isoscel " <<"\n"<<endl;
  51.  
  52. }
  53. void Triunghi_echilateral::verificaEC()
  54. {
  55. if(a==b&&a==c)
  56. cout<<"Triunghiul este echilateral " <<"\n" <<endl ;
  57. else
  58. cout<<"Triunghiul nu este echilateral " <<"\n" <<endl ;
  59.  
  60. }
  61. int main()
  62. {
  63.  
  64. Triunghi_isoscel c;
  65. c.citire();
  66. c.arieperimetru();
  67. c.verificaIS();
  68. c.verificaEC();
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement