fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct point{
  4. double x,y;
  5. point(){}
  6. point(double a,double b){
  7. x=a;y=b;
  8. }
  9. void read(){
  10. scanf("%lf%lf",&x,&y);
  11. }
  12. bool isorigin(){
  13. return (x<1e-8&&y<1e-8);
  14. }
  15. point operator + (point p){
  16. return point(x+p.x,y+p.y);
  17. }
  18. point operator - (point p){
  19. return point(x-p.x,y-p.y);
  20. }
  21. point operator * (double r){
  22. return point(r*x,r*y);
  23. }
  24.  
  25. }A,B,C,D,E,F;
  26. double area(point a,point b,point c){
  27. return (a.x*b.y+b.x*c.y+c.x*a.y-a.y*b.x-b.y*c.x-c.y*a.x);
  28. }
  29. int main(){
  30. while(true){
  31. A.read();
  32. B.read();
  33. C.read();
  34. D.read();
  35. E.read();
  36. F.read();
  37. if(A.isorigin()&&B.isorigin()&&C.isorigin()&&D.isorigin()&&E.isorigin()&&F.isorigin()){
  38. break;
  39. }
  40. double r=area(D,E,F)/area(A,B,C)/2;
  41. point H=A+(C-A)*r;
  42. point G=B+(H-A);
  43. printf("%.3lf %.3lf %.3lf %.3lf\n",G.x,G.y,H.x,H.y);
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0s 3300KB
stdin
0 0 5 0 0 5 3 2 7 2 0 4 
1.3 2.6 12.1 4.5 8.1 13.7 2.2 0.1 9.8 6.6 1.9 6.7 
0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
stdout
5.000 0.800 0.000 0.800
13.756 7.204 2.956 5.304