标签:
Description
Input
Output
Sample Input
Sample Output
#include<cmath> #include<cstdio> #include<algorithm> using namespace std; const double PI = acos(-1.0); 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); } bool operator < (const Point &other){ return y < other.y || (y == other.y && x < other.x); } }; 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() { int t; Point p[3]; scanf("%d", &t); while(t--) { p[0].scan(); p[1] = rotate(p[0], PI * 2 / 3);//逆时针旋转120度 p[2] = rotate(p[0], -PI * 2 / 3);//顺时针旋转120度 if(p[2] < p[1]) swap(p[1], p[2]); p[1].print(); putchar(‘ ‘); p[2].print(); putchar(‘\n‘); } return 0; }
标签:
原文地址:http://www.cnblogs.com/llfj/p/5701451.html