Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- class trikampis
- {
- private:
- int x1, y1, x2, y2, x3, y3;
- double S;
- public:
- trikampis():x1(0),y1(0),x2(0),y2(0), x3(0), y3(0){}
- trikampis(int a, int b, int c, int d, int e, int f):x1(a),y1(b),x2(c),y2(d),x3(e),y3(f){};
- ~trikampis(){}
- void ived()
- {
- cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
- }
- void plotas()
- {
- double a, b, c, p;
- a =sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
- b =sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
- c =sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
- p = (a+b+c)/2.;
- S = sqrt(p*(p-a)*(p-b)*(p-c));
- }
- double graz_plotas()
- {
- return S;
- }
- };
- int main()
- {
- int n;
- double plot;
- double min = 100000000;
- trikampis T[100];
- cin >> n;
- for (int i = 0; i < n; i++) {
- T[i].ived();
- T[i].plotas();
- if(min > T[i].graz_plotas() && T[i].graz_plotas() > 0)
- {
- min = T[i].graz_plotas();
- }
- }
- if(min != 10000000000000000)
- {
- cout << fixed << setprecision(2) << min << endl;
- } else {
- cout <<"NO" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement