A:Rescue The Princess

題目鏈接: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>
 }   


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章