标签:
Description
Input
Output
Sample Input
Sample Output
#include <iostream> #include<cmath> #include<algorithm> #include<cstdio> using namespace std; const double PI=acos(-1.0); struct Point { double x; double y; Point(double x = 0, double y = 0): x(x), y(y){} }; typedef Point Vector; Vector Rotate(Vector A, double rad)//向量旋转公式 { return Vector(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad)); } int main() { Point point[3]; int n; scanf("%d",&n); while(n--) { scanf("%lf %lf",&point[0].x,&point[0].y); point[1]=Rotate(point[0],PI*2/3);//逆时针旋转120度 point[2]=Rotate(point[0],-PI*2/3);//顺时针旋转120度 int maxPoint=(point[1].y<point[2].y || point[1].y==point[2].y && point[1].x<point[2].x)?1:2;//排序 if(maxPoint==1) printf("%.3lf %.3lf %.3lf %.3lf\n",point[1].x,point[1].y,point[2].x,point[2].y); if(maxPoint==2) printf("%.3lf %.3lf %.3lf %.3lf\n",point[2].x,point[2].y,point[1].x,point[1].y); } return 0; }
标签:
原文地址:http://www.cnblogs.com/gdvxfgv/p/5689469.html