fork download
  1. //Bai 1
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. class tg{
  5. private:
  6. float a,b,c,p;
  7. public:
  8. void nhap(){
  9. cout<<"Cho tam giac abc, co:\n";
  10. cout<<"Nhap a: "; cin>>a;
  11. cout<<"Nhap b: "; cin>>b;
  12. cout<<"Nhap c: "; cin >>c;
  13. cout<<endl;
  14. }
  15. void xuat(){
  16. cout<<"("<<a<<","<<b<<","<<c<<")\n";
  17. }
  18. string kt(){
  19. if(a == b && b == c && c == a ) return "La tam giac deu\n";
  20. if(a == b || b == c || c == a ) return "La tam giac can\n";
  21. else if(a*a + b*b == c*c || a*a == b*b + c*c || b*b ==a*a +c*c )return"La tam giac vuong\n";
  22. else return "La tam giac thuong.\n";
  23. }
  24. void tinh(){
  25. p = (a+b+c)/2;
  26. cout<<"Chu vi tam giac la: "<<p*2<<endl;
  27. cout<<"Dien tich tam giac la: "<<sqrt(p*(p-a)*(p-b)*(p-c))<<endl;
  28. }
  29. };
  30. int main(){
  31. tg t;
  32. t.nhap();
  33. cout<<t.kt();
  34. t.tinh();
  35.  
  36. }
Success #stdin #stdout 0s 5288KB
stdin
4
5
6
stdout
Cho tam giac abc, co:
Nhap a: Nhap b: Nhap c: 
La tam giac thuong.
Chu vi tam giac la: 15
Dien tich tam giac la: 9.92157