标签:
Description
Input
Output
Sample Input
Sample Output
#include<cmath> #include<cstdio> #include<algorithm>//交换函数 using namespace std; const double PI = acos(-1.0);//就是pi的值 struct Point { double x, y; Point(double x = 0, double y = 0): x(x), y(y){} void scan() { scanf("%lf%lf", &x, &y); } void print() { printf("%.3lf %.3lf", x, y); } }; Point rotate(Point A, double rad) { return Point(A.x * cos(rad) - A.y * sin(rad), A.y * cos(rad) + A.x * sin(rad));//旋转向量公式 } int main() { int i; Point p[3]; scanf("%d", &i); while(i--) { p[0].scan(); p[1] = rotate(p[0], PI * 2 / 3);//逆时针旋转120度 p[2] = rotate(p[0], -PI * 2 / 3);//顺时针旋转120度 if(p[2].y < p[1].y||(p[2].y == p[1].y && p[2].x < p[1].x)) swap(p[1], p[2]);//交换 p[1].print(); // printf(" "); p[2].print(); // printf("\n"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/shadervio/p/5696971.html