Advertisement
Guest User

Untitled

a guest
May 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. class triangle
  7. {
  8. private:
  9. double x1, x2, x3, y1, y2, y3, plot;
  10. public:
  11. triangle():x1(0),x2(0),x3(0),y1(0),y2(0),y3(0){}
  12. triangle(int a,int b, int c, int d, int e, int f) :x1(a),x2(b),x3(c),y1(d),y2(e),y3(f){}
  13. ~triangle(){}
  14.  
  15. void ivedimas()
  16. {
  17. cin>>x1>>x2>>x3>>y1>>y2>>y3;
  18. }
  19.  
  20. double plotas()
  21. {
  22. plot=(1/2.)*abs((((x2-x1)*(y3-y1))-((x3-x1)*(y2-y1))));
  23. return plot;
  24. }
  25.  
  26. void isvedimas()
  27. {
  28. cout<<plot<<endl;
  29. }
  30. };
  31.  
  32.  
  33. int main()
  34. {
  35. triangle T[100];
  36. int n;
  37. double sum=0;
  38. cin>>n;
  39. for (int i=0; i<n; i++)
  40. {
  41. T[i].ivedimas();
  42. sum+=T[i].plotas();
  43. }
  44.  
  45. if(sum!=0)
  46. cout<<setprecision(3)<<fixed<<sum<<endl;
  47. else
  48. cout<<"NO"<<endl;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement