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 |
晕了,谁能帮忙看看哪里错了?#include <cstdio> #include <cmath> using namespace std; int main() { double a,b,f,h,k,r,c,d,e,a1,a2,b1,b2,c1,c2,p,s,flag=0; char fh,fk,fc,fd,fe; while(scanf("%lf %lf %lf %lf %lf %lf",&a1,&a2,&b1,&b2,&c1,&c2)!=EOF) { if(flag) printf("\n"); flag=1; a=sqrt((a1-b1)*(a1-b1)+(a2-b2)*(a2-b2)); b=sqrt((a1-c1)*(a1-c1)+(a2-c2)*(a2-c2)); f=sqrt((b1-c1)*(b1-c1)+(b2-c2)*(b2-c2)); p=(a+b+f)/2.0; s=sqrt(p*(p-a)*(p-b)*(p-f)); r=0.25*(a*b*f)/s; if(a1!=b1) { k=(b1*b1+b2*b2-c1*c1-c2*c2-(b1-c1)*(a1*a1+a2*a2-b1*b1-b2*b2)/(a1-b1))*(a1-b1)/(2*(b1-c1)*(b2-a2)-2*(a1-b1)*(c2-b2)); h=(2*(b2-a2)*k+a1*a1+a2*a2-b1*b1-b2*b2)/(2*(a1-b1)); } else { k=(a1*a1+a2*a2-c1*c1-c2*c2-(a1-c1)*(b1*b1+b2*b2-c1*c1-c2*c2)/(b1-c1))*(b1-c1)/(2*(a1-c1)*(c2-b2)-2*(c2-a2)*(b1-c1)); h=(2*(c2-b2)*k+b1*b1+b2*b2-c1*c1-c2*c2)/(2*(b1-c1)); } c=2*h*(-1); d=2*k*(-1); e=h*h+k*k-r*r; if(h<0) {fh='+';h=h*(-1);} else fh='-'; if(k<0) {fk='+';k=k*(-1);} else fk='-'; if(c<0) {fc='-';c=c*(-1);} else fc='+'; if(d<0) {fd='-';d=d*(-1);} else fd='+'; if(e<0) {fe='-';e=e*(-1);} else fe='+'; printf("(x %c %.3lf)^2 + (y %c %.3lf)^2 = %.3lf^2\n",fh,h,fk,k,r); printf("x^2 + y^2 %c %.3lfx %c %.3lfy %c %.3lf = 0\n",fc,c,fd,d,fe,e); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator