題目鏈接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2603
題意:已知等邊三角形的一條邊和兩個定點,求另一個頂點的座標
解題思路:極座標
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
const double PI=3.1415926535;
int main()
{
int Case;
scanf("%d",&Case);
double a[3],b[3];
while(Case--)
{
scanf("%lf%lf%lf%lf",&a[0],&a[1],&b[0],&b[1]);
double r=atan2(b[1]-a[1],b[0]-a[0]);
double l=sqrt((b[1]-a[1])*(b[1]-a[1])+(b[0]-a[0])*(b[0]-a[0]));
a[2]=a[0]+l*cos(r+PI/3);
b[2]=a[1]+l*sin(r+PI/3);
printf("(%.2lf,%.2lf)\n",a[2],b[2]);
}
return 0;<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
}