| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
有没有新的测试数据?我的WA……#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <malloc.h>
#define M_PI 3.14159265358979323846
double cal_line(double x1,double y1, double x2, double y2){
return(sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2)));
}
double gcd(double a, double b){
double r;
for(;r>1;){
r=a-b*((int)(a/b));
a=b;b=r;
}
return a;
}
int main(){
int times, *out;
double x[3], y[3],x_out,y_out;
int i,j;
double la,lb,lc;
double a,b,c;
scanf("%d",×);
out=calloc(times,sizeof(double));
for(j=0;j<times;j++){
for(i=0;i<3;i++){
scanf("%lf",&x[i]);
scanf("%lf",&y[i]);
}
lc=cal_line(x[0],y[0],x[1],y[1]);
lb=cal_line(x[0],y[0],x[2],y[2]);
la=cal_line(x[1],y[1],x[2],y[2]);
a=acos((lc*lc + lb*lb - la*la)/(2*lb*lc))*2/M_PI*180;
b=acos((lc*lc + la*la - lb*lb)/(2*la*lc))*2/M_PI*180;
c=acos((la*la + lb*lb - lc*lc)/(2*lb*la))*2/M_PI*180;
*(out+j)=(int)(360/gcd(a,b));
}
for(i=0;i<times;i++)
printf("%d\n",*(out+i));
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator