SHARE
TWEET

Untitled

a guest May 21st, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. class trikampis
  6. {
  7.   private:
  8.       int x1, y1, x2, y2, x3, y3;
  9.       double S;
  10.   public:
  11.       trikampis():x1(0),y1(0),x2(0),y2(0), x3(0), y3(0){}
  12.       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){};
  13.       ~trikampis(){}
  14.   void ived()
  15.   {
  16.     cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  17.   }
  18.   void plotas()
  19.   {
  20.     double a, b, c, p;
  21.     a =sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
  22.     b =sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
  23.     c =sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
  24.  
  25.     p = (a+b+c)/2.;
  26.     S = sqrt(p*(p-a)*(p-b)*(p-c));
  27.  
  28.   }
  29.   double graz_plotas()
  30.   {
  31.     return S;
  32.   }
  33.  
  34.  
  35. };
  36.  
  37. int main()
  38. {
  39.   int n;
  40.   double plot;
  41.   double min = 100000000;
  42.  
  43.   trikampis T[100];
  44.  
  45.   cin >> n;
  46.  
  47.   for (int i = 0; i < n; i++) {
  48.     T[i].ived();
  49.     T[i].plotas();
  50.     if(min > T[i].graz_plotas() && T[i].graz_plotas() > 0)
  51.     {
  52.       min = T[i].graz_plotas();
  53.     }
  54.   }
  55.  
  56. if(min != 10000000000000000)
  57. {
  58.   cout << fixed << setprecision(2) << min << endl;
  59. } else {
  60.   cout <<"NO" << endl;
  61. }
  62.  
  63. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top