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<stdio.h> #include<math.h> #include<string.h> int main() { int i,j,k,n,i0,sum,an[104][103],d[104],m; double e[101][4],a,b,c; while(1) {for(i=1;i<=103;i++) for(j=1;j<=102;j++)an[i][j]=0; for(i=1;i<=102;i++)d[i]=1; scanf("%d",&n); if(n==-1)break; //scanf("%lf%lf%lf",&a,&b,&c); //if(n==0){scanf("%lf%lf%lf",&a,&b,&c);printf("1\n");continue;} m=0; for(i=1;i<=n;i++) for(j=1;j<=3;j++) {scanf("%lf",&e[i][j]);} if(n==1||n==0){printf("1\n");continue;} for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) {if(sqrt((e[i][1]-e[j][1])*(e[i][1]-e[j][1])+(e[i][2]-e[j][2])*(e[i][2]-e[j][2])) <(e[i][3]+e[j][3])&&sqrt((e[i][1]-e[j][1])*(e[i][1]-e[j][1])+ (e[i][2]-e[j][2])*(e[i][2]-e[j][2]))>fabs(e[i][3]-e[j][3])) {an[i][j]+=1; an[j][i]=an[i][j];} } for(k=1;k<=n;k++) { //if(i!=k) d[i]+=an[i][k]; } if(d[i]>m)m=d[i]; }//for for(k=1;k<=n;k++)d[n]+=an[n][k]; if(d[n]>m)m=d[n]; //for(i=1;i<=n;i++) //printf("%d ",d[i]); printf("The largest component contains %d rings\n",m); }//while }//main Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator