Advertisement
osipyonok

1510

May 21st, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. #define INF 1000010000
  4. #define nl '\n'
  5. #define pb push_back
  6. #define ppb pop_back
  7. #define mp make_pair
  8. #define fi first
  9. #define se second
  10. #define pii pair<int,int>
  11. #define pdd pair<double,double>
  12. #define all(c) (c).begin(), (c).end()
  13. #define SORT(c) sort(all(c))
  14. #define rep(i,n) for( int i = 0; i < n; ++i )
  15. #define repi(i,n) for( int i = 1 ; i <= n; ++i )
  16. #define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
  17. #define repf(j,i,n) for( int j = i ; j < n ; ++j )
  18. #define die(s) {std::cout << s << nl;}
  19. #define dier(s) {std::cout << s; return 0;}
  20. #define vi vector<int>
  21. typedef long long ll;
  22.  
  23. using namespace std;
  24.  
  25.  
  26. int main() {
  27.     ios_base::sync_with_stdio(false);
  28.     cin.tie(NULL);
  29.     cout.precision(3);
  30.     cout.setf(ios::fixed);
  31.     double x , y , x1 , y1 , x2 , y2 , x3 , y3 , r;
  32.     while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
  33.         x=((y3-y2)/2+(x1-x3)*(x1+x3)/2/(y1-y3)-(x1-x2)*(x1+x2)/2/(y1-y2))/((x1-x3)/(y1-y3)-(x1-x2)/(y1-y2));
  34.         y=((x3-x2)/2+(y1-y3)*(y1+y3)/2/(x1-x3)-(y1-y2)*(y1+y2)/2/(x1-x2))/((y1-y3)/(x1-x3)-(y1-y2)/(x1-x2));
  35.         if(x1==x2)  y = (y1 + y2) / 2;
  36.         if(x1==x3)  y = (y1 + y3) / 2;
  37.         if(y1==y2)  x = (x1 + x2) / 2;
  38.         if(y1==y3)  x = (x1 + x3) / 2;
  39.         r = sqrt((x - x1)*(x - x1) + (y - y1)*(y - y1));
  40.         if(fabs(x)!=0.) cout << "(";
  41.         cout << "x";
  42.         if(fabs(x)!=0.){
  43.             if(x >= 0) cout << " - ";
  44.             else cout << " + ";
  45.             cout << fabs(x) << ")";
  46.         }
  47.         cout << "^2 + ";
  48.         if(fabs(y)!=0.) cout << "(";
  49.         cout << "y";
  50.         if(fabs(y)!=0.){
  51.             if(y >= 0) cout << " - ";
  52.             else cout << " + ";
  53.             cout << fabs(y) << ")";
  54.         }
  55.         cout << "^2 = " << r << "^2" << nl;
  56.        
  57.         cout << "x^2 + y^2 ";
  58.         if(x != 0.){
  59.             if(x<0) cout << "+ ";
  60.             else cout << "- ";
  61.             cout << fabs(x*2) << "x ";
  62.         }
  63.         if(y != 0.){
  64.             if(y<0) cout << "+ ";
  65.             else cout << "- ";
  66.             cout << fabs(y*2) << "y ";
  67.         }
  68.         if(x , y , x*x + y*y - r*r != 0.){
  69.             if(x , y , x*x + y*y - r*r>0) cout << "+ ";
  70.             else cout << "- ";
  71.             cout << fabs(x*x + y*y - r*r) << " ";
  72.         }
  73.         cout << "= 0" << nl << nl;
  74.     }
  75.     return 0;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement