Advertisement
osipyonok

Untitled

May 30th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.19 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. int main() {
  26.     ios_base::sync_with_stdio(false);
  27.     cin.tie(NULL);
  28.     cout.precision(3);
  29.     cout.setf(ios::fixed);
  30.     double x , y , x1 , y1 , x2 , y2 , x3 , y3 , r;
  31.     while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3){
  32.         stringstream str;
  33.         str.precision(3);
  34.         str.setf(ios::fixed);
  35.         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));
  36.                 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));
  37.         if(x1==x2)  y = (y1 + y2) / 2;
  38.                 if(x1==x3)  y = (y1 + y3) / 2;
  39.                 if(y1==y2)  x = (x1 + x2) / 2;
  40.                 if(y1==y3)  x = (x1 + x3) / 2;
  41.         r = sqrt((x - x1)*(x - x1) + (y - y1)*(y - y1));
  42.         if(fabs(x)!=0.) str << "(";
  43.         str << "x";
  44.         if(fabs(x)!=0.){
  45.             if(x >= 0) str << " - ";
  46.                 else str << " + ";
  47.             str << fabs(x) << ")";
  48.         }
  49.         str << "^2 + ";
  50.         if(fabs(y)!=0.) str << "(";
  51.         str << "y";
  52.         if(fabs(y)!=0.){
  53.             if(y >= 0) str << " - ";
  54.                 else str << " + ";
  55.             str << fabs(y) << ")";
  56.         }
  57.         str << "^2 = " << r << "^2" << nl;
  58.        
  59.         str << "x^2 + y^2 ";
  60.         if(x != 0.){
  61.             if(x<0) str << "+ ";
  62.                 else str << "- ";
  63.             str << fabs(x*2) << "x ";
  64.         }
  65.         if(y != 0.){
  66.             if(y<0) str << "+ ";
  67.                 else str << "- ";
  68.             str << fabs(y*2) << "y ";
  69.         }
  70.         if(x*2,y*2,x*x+y*y-r*r != 0.){
  71.             if(x*2,y*2,x*x+y*y-r*r>0) str << "+ ";
  72.                 else str << "- ";
  73.             str << fabs(x*x+y*y-r*r) << " ";
  74.         }
  75.         str << "= 0" << nl << nl;
  76.         string ans = str.str();
  77.  
  78.         cout << ans;
  79.     }
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement