Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- class triangle
- {
- private:
- double x1, x2, x3, y1, y2, y3, plot;
- public:
- triangle():x1(0),x2(0),x3(0),y1(0),y2(0),y3(0){}
- 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){}
- ~triangle(){}
- void ivedimas()
- {
- cin>>x1>>x2>>x3>>y1>>y2>>y3;
- }
- double plotas()
- {
- plot=(1/2.)*abs((((x2-x1)*(y3-y1))-((x3-x1)*(y2-y1))));
- return plot;
- }
- void isvedimas()
- {
- cout<<plot<<endl;
- }
- };
- int main()
- {
- triangle T[100];
- int n;
- double sum=0;
- cin>>n;
- for (int i=0; i<n; i++)
- {
- T[i].ivedimas();
- sum+=T[i].plotas();
- }
- if(sum!=0)
- cout<<setprecision(3)<<fixed<<sum<<endl;
- else
- cout<<"NO"<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement