id
int32
0
32.5k
code
stringlengths
95
8.4k
label
stringclasses
65 values
31,800
int main(){ int n,i; scanf("%d",&n); int sz[30]; for(i=0;i<(3*n);i++){ scanf("%d",&sz[i]); } double dd[10][10]; int j,k; for(i=0;i<n;i++){ for(j=0;j<n;j++){ dd[i][j]=sqrt(1.0*((sz[3*i]-sz[3*j])*(sz[3*i]-sz[3*j])+(sz[3*i+1]-sz[3*j+1])*(sz[3*i+1]-sz[3*j+1])+(sz[3*i+2]-sz[3*j+2])*(sz[3*i+2]-sz[3*j+2]))); } } double xin[45]; int d,e; int di[45],dj[45]; double max=0; for(k=0;k<n*(n-1)/2;k++){ for(i=n-1;i>=0;i--){ for(j=n-1;j>=0;j--){ if(dd[i][j]>=max&&k==0&&i!=j){ di[k]=i; dj[k]=j; max=dd[i][j]; } if(dd[i][j]>=max&&k!=0&&i!=j){ di[k]=i; dj[k]=j; max=dd[i][j]; } } } dd[di[k]][dj[k]]=-1; dd[dj[k]][di[k]]=-1; xin[k]=max; max=0; } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[3*di[i]],sz[3*di[i]+1],sz[3*di[i]+2],sz[3*dj[i]],sz[3*dj[i]+1],sz[3*dj[i]+2],xin[i]); } return 0; }
64
31,801
int main(){ int n,i,j,dx,dy,dz,o=0; scanf("%d",&n); int x[10],y[10],z[10]; double ji[100]; for(i=0;i<n;i++){ scanf("%d%d%d",&(x[i]),&(y[i]),&(z[i])); }struct pp{ int xi[2],yi[2],zi[2]; double jl; }pp[100],e; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ dx=x[j]-x[i]; dy=y[j]-y[i]; dz=z[j]-z[i]; pp[o].xi[0]=x[i]; pp[o].xi[1]=x[j]; pp[o].yi[0]=y[i]; pp[o].yi[1]=y[j]; pp[o].zi[0]=z[i]; pp[o].zi[1]=z[j]; pp[o].jl=sqrt(dx*dx+dy*dy+dz*dz); o++; } } for(i=0;i<n*(n-1)/2;i++){ for(j=n*(n-1)/2-1;j>=i+1;j--){ if(pp[j].jl>pp[j-1].jl){ e=pp[j-1]; pp[j-1]=pp[j]; pp[j]=e; } } }for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",pp[i].xi[0],pp[i].yi[0],pp[i].zi[0],pp[i].xi[1],pp[i].yi[1],pp[i].zi[1],pp[i].jl); } return 0; }
64
31,802
int main() { int n,i,k,j=0,m,f,g; scanf("%d",&n); int s[10][3],b[50][3],d[50][3]; double c[50],r,e; for(i=0;i<n;i++){ for(k=0;k<3;k++){ scanf("%d",&s[i][k]); } } for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ r=sqrt((s[i][0]-s[k][0])*(s[i][0]-s[k][0])+(s[i][1]-s[k][1])*(s[i][1]-s[k][1])+(s[i][2]-s[k][2])*(s[i][2]-s[k][2])); b[j][0]=s[i][0]; b[j][1]=s[i][1]; b[j][2]=s[i][2]; d[j][0]=s[k][0]; d[j][1]=s[k][1]; d[j][2]=s[k][2]; c[j]=r; j++; } } for(i=1;i<n*(n-1)/2;i++){ for(k=0;k<n*(n-1)/2-i;k++){ if(c[k]<c[k+1]){ e=c[k+1]; c[k+1]=c[k]; c[k]=e; for(m=0;m<3;m++){ f=b[k+1][m]; b[k+1][m]=b[k][m]; b[k][m]=f; g=d[k+1][m]; d[k+1][m]=d[k][m]; d[k][m]=g; } } } } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i][0],b[i][1],b[i][2],d[i][0],d[i][1],d[i][2],c[i]); } return 0; }
64
31,803
int main() { int n,i,j,count=1; double x[20],y[20],z[20],t; cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i];//?xyz?? } struct position//????????????? { double x;double a; double y;double b; double z;double c; double d; }p[100]; for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { p[count].x=x[i];p[count].a=x[j]; p[count].y=y[i];p[count].b=y[j]; p[count].z=z[i];p[count].c=z[j]; p[count].d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));//??? count++; } } for(i=count-1;i>0;i--) { for(j=1;j<i;j++) { if(p[j].d<p[j+1].d) { swap(p[j].x,p[j+1].x); swap(p[j].y,p[j+1].y); swap(p[j].z,p[j+1].z); swap(p[j].a,p[j+1].a); swap(p[j].b,p[j+1].b); swap(p[j].c,p[j+1].c); swap(p[j].d,p[j+1].d);//?????????? } } } for(i=1;i<=count-1;i++) { cout<<'('<<(int)p[i].x<<','<<(int)p[i].y<<','<<(int)p[i].z<<')'<<'-'<<'('<<(int)p[i].a<<','<<(int)p[i].b<<','<<(int)p[i].c<<')'<<'='<<fixed<<setprecision(2)<<p[i].d<<endl; } return 0; }
64
31,804
int main () { struct distance { int point1[3]; int point2[3]; double dis; }; struct distance d[100],middle; int i,j,k,n,point[100][3]; cin >> n; for (i=0;i<n;i++) { for (j=0;j<3;j++) { cin >> point[i][j]; } } j=0; k=1; for (i=0;i<n*(n-1)/2;i++) { d[i].point1[0]=point[j][0]; d[i].point1[1]=point[j][1]; d[i].point1[2]=point[j][2]; d[i].point2[0]=point[k][0]; d[i].point2[1]=point[k][1]; d[i].point2[2]=point[k][2]; d[i].dis=sqrt((d[i].point2[0]-d[i].point1[0])*(d[i].point2[0]-d[i].point1[0])+ (d[i].point2[1]-d[i].point1[1])*(d[i].point2[1]-d[i].point1[1]) +(d[i].point2[2]-d[i].point1[2])*(d[i].point2[2]-d[i].point1[2])); k++; if (k==n) { j=j+1; k=j+1; } } for (i=0;i<n*(n-1)/2;i++) { for (j=n*(n-1)/2-1;j>i;j--) { if (d[j].dis>d[j-1].dis) { middle=d[j]; d[j]=d[j-1]; d[j-1]=middle; } } } for (i=0;i<n*(n-1)/2;i++) cout << fixed << setprecision(2) << "(" << d[i].point1[0] << "," << d[i].point1[1] << "," << d[i].point1[2] << ")-(" << d[i].point2[0] << "," << d[i].point2[1] << "," << d[i].point2[2] << ")=" << d[i].dis << endl; return 0; }
64
31,805
int main(){ int n,i,j,k,f; k=0; int x[10]; int y[10]; int z[10]; int m[50][6]; double r[50]; double e; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n-1;i++){ for(j=n-1;j>i;j--){ r[k]=sqrt(1.0*((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))); m[k][0]=x[i]; m[k][1]=y[i]; m[k][2]=z[i]; m[k][3]=x[j]; m[k][4]=y[j]; m[k][5]=z[j]; k++; } } for(i=1;i<=n*(n-1)/2;i++){ for(j=0;j<n*(n-1)/2-i;j++){ if(r[j]>=r[j+1]){ e=r[j+1]; r[j+1]=r[j]; r[j]=e; f=m[j+1][0]; m[j+1][0]=m[j][0]; m[j][0]=f; f=m[j+1][1]; m[j+1][1]=m[j][1]; m[j][1]=f; f=m[j+1][2]; m[j+1][2]=m[j][2]; m[j][2]=f; f=m[j+1][3]; m[j+1][3]=m[j][3]; m[j][3]=f; f=m[j+1][4]; m[j+1][4]=m[j][4]; m[j][4]=f; f=m[j+1][5]; m[j+1][5]=m[j][5]; m[j][5]=f; } } } for(i=n*(n-1)/2-1;i>=0;i--){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",m[i][0],m[i][1],m[i][2],m[i][3],m[i][4],m[i][5],r[i]); } return 0; }
64
31,806
/*???? ??*/ struct distance { int x1,y1,z1,x2,y2,z2; double s; }d[45],temp; int main() { int n,i,j,k,a[10][3]; cin>>n; for(i=0;i<n;i++){ for(j=0;j<3;j++) cin>>a[i][j];} k=0; while(k<n*(n-1)/2){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ d[k].x1=a[i][0]; d[k].y1=a[i][1]; d[k].z1=a[i][2]; d[k].x2=a[j][0]; d[k].y2=a[j][1]; d[k].z2=a[j][2]; d[k].s =sqrt((d[k].x1-d[k].x2)*(d[k].x1-d[k].x2) +(d[k].y1-d[k].y2)*(d[k].y1-d[k].y2) +(d[k].z1-d[k].z2)*(d[k].z1-d[k].z2)); k++;}}} for(i=0;i<n*(n-1)/2;i++){ for(j=0;j<n*(n-1)/2-1;j++){ if(d[j].s<d[j+1].s) {temp=d[j];d[j]=d[j+1];d[j+1]=temp;}}} for(i=0;i<n*(n-1)/2;i++) cout<<"("<<d[i].x1<<","<<d[i].y1<<","<<d[i].z1 <<")-("<<d[i].x2<<","<<d[i].y2<<","<<d[i].z2<<")=" <<fixed<<setprecision(2)<<d[i].s<<endl; return 0; }
64
31,807
int main(){ int n,i,j,k,LEN; int a[30]; double b[135],e; scanf("%d",&n); for(i=0;i<=3*n-1;i++){ scanf("%d",&a[i]); } k=0; for(i=0;i<=3*n-4;i=i+3){ for(j=i+3;j<=3*n-1;j=j+3){ b[k]=sqrt((a[i]-a[j])*(a[i]-a[j])+(a[i+1]-a[j+1])*(a[i+1]-a[j+1])+(a[i+2]-a[j+2])*(a[i+2]-a[j+2])); b[k+1]=i; b[k+2]=j; k+=3; } } LEN=n*(n-1)/2; for(k = 1;k<=LEN;k++){ for(i =0;i<LEN-k; i++){ if(b[3*i]<b[3*i+3]){ e=b[3*i+3]; b[3*i+3]=b[3*i]; b[3*i]=e; e=b[3*i+4]; b[3*i+4]=b[3*i+1]; b[3*i+1]=e; e=b[3*i+5]; b[3*i+5]=b[3*i+2]; b[3*i+2]=e; } } } for(i=0;i<=3*n*(n-1)/2-1;i=i+3){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[(int)b[i+1]],a[(int)b[i+1]+1],a[(int)b[i+1]+2],a[(int)b[i+2]],a[(int)b[i+2]+1],a[(int)b[i+2]+2],b[i]); } return 0; }
64
31,808
struct point { int x; int y; int z; }; //????????? struct point dian[101]; double distance(struct point dian[],int i,int j){ int x=dian[i].x-dian[j].x; int y=dian[i].y-dian[j].y; int z=dian[i].z-dian[j].z; double dis=(double)(x*x+y*y+z*z); return sqrt(dis); } int main() { int n,i,j; int t=0,k=0; double a[105]; cin>>n; for(i=0;i<n;++i) cin>>dian[i].x>>dian[i].y>>dian[i].z; for(i=0;i<n;++i) for(j=i+1;j<n;++j) { int t=0; while(t<k+1 &&(a[t]-distance(dian,i,j)>0.00001 ||distance(dian,i,j)-a[t]>0.00001)) t++; if(t==k+1){ a[k]=distance(dian,i,j); k++; } } int count=k; for(i=0;i<count;i++) for(j=0;j<count-i;j++) if(a[j]<a[j+1]){ double temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } k=0; while(k<count){ for(i=0;i<n;++i){ for(j=i+1;j<n;++j){ if(abs(a[k]-distance(dian,i,j))<0.0000001) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n\n",dian[i].x,dian[i].y,dian[i].z,dian[j].x,dian[j].y,dian[j].z,distance(dian,i,j)); } } k++; } //while(1); return 0; }
64
31,809
unsigned int com[45][2]; float dis[45]; void swap(int i,int j) { unsigned int t_1[2]; float t_2; t_2=dis[i]; dis[i]=dis[j]; dis[j]=t_2; t_1[0]=com[i][0]; com[i][0]=com[j][0]; com[j][0]=t_1[0]; t_1[1]=com[i][1]; com[i][1]=com[j][1]; com[j][1]=t_1[1]; } int main(void) { int i,j,n,s=0,coord[10][3]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d %d %d ",&coord[i][0],&coord[i][1],&coord[i][2]); for(i=0;i<n;i++) for(j=i+1;j<n;j++) { com[s][0]=i; com[s][1]=j; dis[s]=sqrt(pow(coord[i][0]-coord[j][0],2)+pow(coord[i][1]-coord[j][1],2)+pow(coord[i][2]-coord[j][2],2)); s++; } for(i=s;i>0;i--) for(j=0;j<i-1;j++) if(dis[j]<dis[j+1]) swap(j,j+1); for(i=0;i<s;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",coord[com[i][0]][0],coord[com[i][0]][1],coord[com[i][0]][2],coord[com[i][1]][0],coord[com[i][1]][1],coord[com[i][1]][2],dis[i]); fclose(stdin); return 0; }
64
31,810
int main() { int i,j,n,k=0,w; int x[10],y[10],z[10]; float d[45],dis[10][10],p=0,q=0,m=0,o=0; cin>>n; for(i=0;i<n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(j=0;j<n-1;j++) { for(i=j+1;i<n;i++) { o=(x[j]-x[i])*(x[j]-x[i]); p=(y[j]-y[i])*(y[j]-y[i]); q=(z[j]-z[i])*(z[j]-z[i]); d[k]=sqrt(o+p+q); k++; } } for(w=1;w<n*(n-1)/2;w++) { for(k=0;k<(n*(n-1))/2-w;k++) { if(d[k]>d[k+1]) { m=d[k+1]; d[k+1]=d[k]; d[k]=m; } } } for(k=n*(n-1)/2-1;k>=0;k--) { if(d[k]!=d[k-1]) { for(j=0;j<n-1;j++) { for(i=j+1;i<n;i++) { o=(x[j]-x[i])*(x[j]-x[i]); p=(y[j]-y[i])*(y[j]-y[i]); q=(z[j]-z[i])*(z[j]-z[i]); if(d[k]==sqrt(o+p+q)) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",x[j],y[j],z[j],x[i],y[i],z[i],d[k]); cout<<endl; } } }}} return 0; }
64
31,811
int main() { int i,j,k,l,m,n,num,tempi; int x[10],y[10],z[10]; float d[100]; float tempd; int dp1[100],dp2[100]; //scan the numbers scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&x[i],&y[i],&z[i]); } num=-1; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { num++; d[num]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); dp1[num]=i; dp2[num]=j; } num++; for(i=0;i<num-1;i++) for(j=i+1;j<num;j++) { if(d[j]>d[i]) { //swap d tempd=d[j]; d[j]=d[i]; d[i]=tempd; //swap dp1 tempi=dp1[i]; dp1[i]=dp1[j]; dp1[j]=tempi; //swap dp2 tempi=dp2[i]; dp2[i]=dp2[j]; dp2[j]=tempi; } if(d[j]==d[i]&&(dp1[j]<dp1[i]||dp1[j]==dp1[i]&&dp2[j]<dp2[i])) { tempd=d[j]; d[j]=d[i]; d[i]=tempd; tempi=dp1[i]; dp1[i]=dp1[j]; dp1[j]=tempi; tempi=dp2[i]; dp2[i]=dp2[j]; dp2[j]=tempi; } } for(i=0;i<num;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[dp1[i]],y[dp1[i]],z[dp1[i]],x[dp2[i]],y[dp2[i]],z[dp2[i]],d[i]); }
64
31,812
/** *@ file 1000012834_005homework.cpp *@ author ??? *@ date 2010-12-15 *@ description * ??????????? */ struct position // ?????????????????? { double distance[1000]; int x; int y; int z; }pos[1000]; // ?????????????pos struct str // ??????????????????? { int point1; int point2; double distance; }length[100], temp; // length?????????,temp??????? int main() { // ??????n,????i,j?????k,??????????num,??????????????? int n, i, j, k, num; cin >> n; for (i = 1; i <= n; i++) { cin >> pos[i].x >> pos[i].y >> pos[i].z; } num= 0; // ????? for (i = 1; i <= n; i++) // ???????????????????length?? { k = 0; // ???????1???????????????? for (j = i + 1; j <= n; j++) { k++; // ?????? num++; // ??????????+1 // ???????????? pos[i].distance[k] = (pos[i].x - pos[j].x) * (pos[i].x - pos[j].x) + (pos[i].y - pos[j].y) * (pos[i].y - pos[j].y) + (pos[i].z - pos[j].z) * (pos[i].z - pos[j].z); // ????????????length?? length[num].point1 = i; length[num].point2 = j; length[num].distance = pos[i].distance[k]; } } // ?????????????????? for (i = 1; i < num; i++) for (j = 1; j <= num - i; j++) { if(length[j].distance < length[j + 1].distance) { temp = length[j]; length[j] = length[j + 1]; length[j + 1] = temp; } } // ???????????? for (i = 1; i <= num; i++) { cout << "(" << pos[length[i].point1].x << "," << pos[length[i].point1].y << "," << pos[length[i].point1].z << ")" << "-" << "(" << pos[length[i].point2].x << "," << pos[length[i].point2].y << "," << pos[length[i].point2].z << ")" << "=" << fixed << setprecision(2) << sqrt(length[i].distance) << endl; } return 0; }
64
31,813
int main() { struct point { int x; int y; int z; }p[10]; //????? struct distant { float d; struct point p1; struct point p2; }dis[45],temp; //???? int n,i,j,k; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z); } i=0; for(j=0;j<n-1;j++) { for(k=j+1;k<n;k++) { dis[i].p1=p[j]; dis[i].p2=p[k]; i=i+1; } } //??????????????????????????? for(i=0;i<n*(n-1)/2;i++) { dis[i].d=sqrt((dis[i].p1.x-dis[i].p2.x)*(dis[i].p1.x-dis[i].p2.x)+(dis[i].p1.y-dis[i].p2.y)*(dis[i].p1.y-dis[i].p2.y)+(dis[i].p1.z-dis[i].p2.z)*(dis[i].p1.z-dis[i].p2.z)); } //????????? for(i=1;i<n*(n-1)/2;i++) { for(j=0;j<n*(n-1)/2-i;j++) { if(dis[j].d<dis[j+1].d) { temp=dis[j]; dis[j]=dis[j+1]; dis[j+1]=temp; } } } //?????????????????????????? for(i=0;i<n*(n-1)/2;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dis[i].p1.x,dis[i].p1.y,dis[i].p1.z,dis[i].p2.x,dis[i].p2.y,dis[i].p2.z,dis[i].d); } return 0; }
64
31,814
int main(){ int n,i,j,t,t2,t3; double t1; int zb[10][3]; double d[60]; int flag[60][2]; scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&zb[i][j]); } } t=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ d[t]=sqrt(1.0*((zb[i][0]-zb[j][0])*(zb[i][0]-zb[j][0])+(zb[i][1]-zb[j][1])*(zb[i][1]-zb[j][1])+(zb[i][2]-zb[j][2])*(zb[i][2]-zb[j][2]))); flag[t][0]=i; flag[t][1]=j; t++; } } for(j=0;j<t-1;j++){ for(i=0;i<t-j-1;i++){ if(d[i]<d[i+1]){ t1=d[i]; d[i]=d[i+1]; d[i+1]=t1; t2=flag[i][0]; flag[i][0]=flag[i+1][0]; flag[i+1][0]=t2; t3=flag[i][1]; flag[i][1]=flag[i+1][1]; flag[i+1][1]=t3; } } } for(i=0;i<t;i++){ printf("(%d,%d,%d)",zb[flag[i][0]][0],zb[flag[i][0]][1],zb[flag[i][0]][2]); printf("-"); printf("(%d,%d,%d)",zb[flag[i][1]][0],zb[flag[i][1]][1],zb[flag[i][1]][2]); printf("=%.2f",d[i]); printf("\n"); } return 0; }
64
31,815
int main(){ int n,a[11],b[11],c[11],i,j,s,q,maxi=0,maxj=1; double d[90][90]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); } for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ s=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]); d[i][j]=sqrt(1.0*s); } } for(q=0;q<n*(n-1)/2;q++){ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(d[i][j]>d[maxi][maxj]){ maxi=i; maxj=j; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[maxi],b[maxi],c[maxi],a[maxj],b[maxj],c[maxj],d[maxi][maxj]); d[maxi][maxj]=0; } return 0; }
64
31,816
int main(){ int n,i,s,j,b; b=0; int x[11],y[11],z[11],a[46],c[46]; double d[46]; double t,f; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } s=n*(n-1)/2; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ f=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); t=sqrt(f); d[b]=t; a[b]=i; c[b]=j; b++; } } for(int k=1;k<=s;k++){ for(b=0;b<s-k;b++){ if(d[b]>d[b+1]){ double e=d[b+1]; d[b+1]=d[b]; d[b]=e; int g=a[b+1]; a[b+1]=a[b]; a[b]=g; int u=c[b+1]; c[b+1]=c[b]; c[b]=u; }else{ if(d[b]==d[b+1]){ if(a[b]<a[b+1]){ double o=d[b+1]; d[b+1]=d[b]; d[b]=o; int p=a[b+1]; a[b+1]=a[b]; a[b]=p; int q=c[b+1]; c[b+1]=c[b]; c[b]=q; }else{ if(a[b]==a[b+1]){ if(c[b]<c[b+1]){ double o=d[b+1]; d[b+1]=d[b]; d[b]=o; int p=a[b+1]; a[b+1]=a[b]; a[b]=p; int q=c[b+1]; c[b+1]=c[b]; c[b]=q; } } } } } } } for(b=s-1;b>=0;b--){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[(a[b])],y[(a[b])],z[(a[b])],x[(c[b])],y[(c[b])],z[(c[b])],d[b]); } return 0; }
64
31,817
int main(){ int n, xz[100], yz[100], zz[100], xx[100], yy[100]; double jl[100]; double j[100]; int c=0; int t, m, l; scanf("%d\n",&n); for(int i=0;i<n;i++){ scanf("%d %d %d",&xz[i], &yz[i], &zz[i]); } for(int a=0;a<n;a++){ for(int b=a+1;b<n;b++){ jl[c]=(zz[b]-zz[a])*(zz[b]-zz[a])+(xz[b]-xz[a])*(xz[b]-xz[a])+(yz[b]-yz[a])*(yz[b]-yz[a]); xx[c]=a; yy[c]=b; c=c+1; } } for(int k=1;k<=c;k++){ for(int i=0;i<c-k;i++){ if(jl[i]<jl[i+1]){ t=jl[i]; jl[i]=jl[i+1]; jl[i+1]=t; m=xx[i]; xx[i]=xx[i+1]; xx[i+1]=m; l=yy[i]; yy[i]=yy[i+1]; yy[i+1]=l; } } } for(int w=0;w<c;w++){ j[w]=sqrt(jl[w]); } for(int s=0;s<c;s++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", xz[xx[s]], yz[xx[s]], zz[xx[s]], xz[yy[s]], yz[yy[s]], zz[yy[s]], j[s]); } return 0;}
64
31,818
int main() { struct jl {int a1;int b1;int c1;int a2;int b2;int c2;float d;}hz[100],t; int n,i,j,a[10],b[10],c[10],k=0; double w; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { w=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); hz[k].a1=a[i];hz[k].b1=b[i];hz[k].c1=c[i]; hz[k].a2=a[j];hz[k].b2=b[j];hz[k].c2=c[j]; hz[k].d=w; k++; } } if(k==1) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[0],b[0],c[0],a[1],b[1],c[1],w); else { for(i=0;i<k-1;i++) for(j=0;j<k-i-1;j++) { if(hz[j].d<hz[j+1].d) { t=hz[j]; hz[j]=hz[j+1]; hz[j+1]=t; } } for(i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",hz[i].a1,hz[i].b1,hz[i].c1,hz[i].a2,hz[i].b2,hz[i].c2,hz[i].d); } return 0; }
64
31,819
//************************ //??????? //????? //???2011-12-14 //************************ int main() { int x[10], y[10], z[10], n, i, j; struct distance { int x1; //?? int y1; int z1; int x2; int y2; int z2; double c; //?? }dis[46]; cin >> n; cout << fixed; for(i = 0;i < n;i++) { cin >> x[i] >> y[i] >> z[i]; //???? } int k = 0; for(i = 0;i < n;i++) //?????????????? for(j = i + 1;j < n;j++) { dis[k].x1 = x[i]; dis[k].y1 = y[i]; dis[k].z1 = z[i]; dis[k].x2 = x[j]; dis[k].y2 = y[j]; dis[k].z2 = z[j]; dis[k++].c = sqrt((dis[k].x1 - dis[k].x2) * (dis[k].x1 - dis[k].x2) + (dis[k].y1 - dis[k].y2) * (dis[k].y1 - dis[k].y2) + (dis[k].z1 - dis[k].z2) * (dis[k].z1 - dis[k].z2)); } int t, t1; for(i = 0;i < n * (n - 1) / 2 - 1;i++) for(j = i + 1;j < n * (n - 1) / 2;j++) { if(dis[j].c - dis[i].c > 1e-6) //?????????????????? { dis[45] = dis[j]; for(t = j, t1 = j;t > i;t--) { dis[t] = dis[--t1]; } dis[i] = dis[45]; } } for(i = 0;i < n * (n - 1) / 2;i++) //?? { cout << "(" << dis[i].x1 << "," << dis[i].y1 << "," << dis[i].z1 << ")" << "-" << "(" << dis[i].x2 << "," << dis[i].y2 << "," << dis[i].z2 << ")" << "=" << setprecision(2) << dis[i].c << endl; } return 0; }
64
31,820
int main() { int a[10][3],i,j,k,n,t=0,b[45],c[45],q,m; float d[45],p,s; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) scanf("%d",&a[i][j]); } for(i=0;i<n;i++) { for(k=i+1;k<n;k++) { s=(a[i][0]-a[k][0])*(a[i][0]-a[k][0])+(a[i][1]-a[k][1])*(a[i][1]-a[k][1])+(a[i][2]-a[k][2])*(a[i][2]-a[k][2]); d[t]=sqrt(s); b[t]=i;c[t]=k; t++; } } for(i=t-1;i>0;i--) { for(j=t-1;j>t-i-1;j--) { if(d[j]>d[j-1]) { p=d[j]; d[j]=d[j-1]; d[j-1]=p; q=b[j]; b[j]=b[j-1]; b[j-1]=q; q=c[j]; c[j]=c[j-1]; c[j-1]=q; } else; } } for(m=0;m<t;m++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[b[m]][0],a[b[m]][1],a[b[m]][2],a[c[m]][0],a[c[m]][1],a[c[m]][2],d[m]); return 0; }
64
31,821
int main(){ int n,i,j,h; double temp; double x[30],y[45][7]; scanf("%d",&n); for(i=0;i<3*n;i++){ scanf("%lf",&(x[i])); } h=0; for(i=0;i<n-1;i++){ for(j=i;j<n-1;j++){ y[h][0]=x[3*i]; y[h][1]=x[3*i+1]; y[h][2]=x[3*i+2]; h++; } } h=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ y[h][3]=x[3*j]; y[h][4]=x[3*j+1]; y[h][5]=x[3*j+2]; y[h][6]=sqrt((y[h][0]-y[h][3])*(y[h][0]-y[h][3])+(y[h][1]-y[h][4])*(y[h][1]-y[h][4])+(y[h][2]-y[h][5])*(y[h][2]-y[h][5])); h++; } } for(i=0;i<(n*(n-1)/2)-1;i++){ for(j=0;j<(n*(n-1)/2)-1;j++){ if(y[j][6]<y[j+1][6]){ for(h=0;h<7;h++){ temp=y[j][h]; y[j][h]=y[j+1][h]; y[j+1][h]=temp; } } } } for(i=0;i<(n*(n-1)/2);i++){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",y[i][0],y[i][1],y[i][2],y[i][3],y[i][4],y[i][5],y[i][6]); } return 0; }
64
31,822
int main() { int n,i,j,a[15],b[15],c[15]; double d[15][15],z[150],q[150]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&a[i],&b[i],&c[i]);} for(i=0;i<n;i++){ for(j=i;j<n;j++){ d[i][j]=sqrt((a[i]-a[j])*(a[i]-a[j])+ (b[i]-b[j])*(b[i]-b[j])+ (c[i]-c[j])*(c[i]-c[j]));}} int t=0; for(i=0;i<n;i++){ for(j=i;j<n;j++){ z[t]=d[i][j]; t++;}} int k; double x; for(k=t-1;k>0;k--){ for(i=0;i<k;i++){ if(z[i]<z[i+1]) {x=z[i]; z[i]=z[i+1]; z[i+1]=x;}}} int p=0; for(i=0;i<150;i++){ if(z[i]!=z[i+1]) {q[p]=z[i]; p++;}} int y; for(y=0;q[y]!=0;y++){ for(i=0;i<n;i++){ for(j=i;j<n;j++){ if(d[i][j]==q[y]){ printf("(%d,%d,%d)-(%d,%d,%d)",a[i],b[i],c[i],a[j],b[j],c[j]); printf("="); printf("%.2lf\n",d[i][j]);}}}} return 0; }
64
31,823
//* * * * * * * * * * * * * * * * * * * * * * * * //*???????? * //*????????.cpp * //*????? 1000012839 * //*???2010.12.18 * //* * * * * * * * * * * * * * * * * * * * * * * * struct Dot { int dot1[3]; // ???????? int dot2[3]; // ???????? double distance; // ??????? } s[45], temp; int main() { int dot[10][3]; // ?????? int n; // ????? int i, j, k; // ????? cin >> n; for (i = 0; i < n; i++) cin >> dot[i][0] >> dot[i][1] >> dot[i][2]; k = 0; for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { s[k].dot1[0] = dot[i][0]; s[k].dot1[1] = dot[i][1]; s[k].dot1[2] = dot[i][2]; s[k].dot2[0] = dot[j][0]; s[k].dot2[1] = dot[j][1]; s[k].dot2[2] = dot[j][2]; s[k].distance = sqrt(pow(dot[i][0] - dot[j][0],2) + pow(dot[i][1] - dot[j][1],2) + pow(dot[i][2] - dot[j][2],2)); k++; // ?????????????? } } for (i = 0; i < k - 1; i++) // ??k?n*(n-1)/2? { for (j = 0; j < k - i; j++) { if (s[j].distance < s[j + 1].distance) { temp = s[j]; s[j] = s[j + 1]; s[j + 1] = temp; // ?????? } } } for (i = 0; i < k; i++) cout << '(' << s[i].dot1[0] << ',' << s[i].dot1[1] << ',' << s[i].dot1[2] << ")-(" << s[i].dot2[0] << ',' << s[i].dot2[1] << ',' << s[i].dot2[2] << ")=" << fixed << setprecision(2) << s[i].distance << endl; return 0; }
64
31,824
int main(){ int n; struct point{ int x,y,z,i; }points[10]; struct jieguo{ struct point pointqian; struct point pointhou; double juliss; }e,jieguos[45]; scanf("%d",&n); int i=0; for(i=0;i<n;i++){ scanf("%d%d%d",&points[i].x,&points[i].y,&points[i].z); } int m=0,k=0; i=0; for(m=0;m<n;m++){ for(k=m+1;k<n;k++){ jieguos[i].pointqian=points[m]; jieguos[i].pointhou=points[k]; jieguos[i].juliss=sqrt((jieguos[i].pointqian.x-jieguos[i].pointhou.x)*(jieguos[i].pointqian.x-jieguos[i].pointhou.x)+(jieguos[i].pointqian.y-jieguos[i].pointhou.y)*(jieguos[i].pointqian.y-jieguos[i].pointhou.y)+(jieguos[i].pointqian.z-jieguos[i].pointhou.z)*(jieguos[i].pointqian.z-jieguos[i].pointhou.z)); i++; } } for(k=1;k<(n*(n-1)/2);k++){ for(i=0;i<(n*(n-1)/2)-k;i++){ if(jieguos[i].juliss<jieguos[i+1].juliss){ e=jieguos[i+1]; jieguos[i+1]=jieguos[i]; jieguos[i]=e; } } } for(i=0;i<(n*(n-1)/2);i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",jieguos[i].pointqian.x,jieguos[i].pointqian.y,jieguos[i].pointqian.z,jieguos[i].pointhou.x,jieguos[i].pointhou.y,jieguos[i].pointhou.z,jieguos[i].juliss); } return 0; }
64
31,825
main() { int i,j,p=0,n,b[10][3]; struct qwe { int a[3]; int b[3]; int jl; }t[45],e; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",*(b+i),*(b+i)+1,*(b+i)+2); for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { t[p].a[0]=b[i][0]; t[p].a[1]=b[i][1]; t[p].a[2]=b[i][2]; t[p].b[0]=b[j][0]; t[p].b[1]=b[j][1]; t[p].b[2]=b[j][2]; t[p].jl=(b[i][0]-b[j][0])*(b[i][0]-b[j][0])+(b[i][1]-b[j][1])*(b[i][1]-b[j][1])+(b[i][2]-b[j][2])*(b[i][2]-b[j][2]); p++; } } for(i=0;i<p;i++) { for(j=0;j<p-i-1;j++) { if(t[j].jl<t[j+1].jl) { e=t[j]; t[j]=t[j+1]; t[j+1]=e; } } } for(i=0;i<p;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",t[i].a[0],t[i].a[1],t[i].a[2],t[i].b[0],t[i].b[1],t[i].b[2],sqrt(t[i].jl)); } }
64
31,826
int main(){ int n,i,j,k,b,c; int x[10],y[10],z[10]; double m[10][10],max=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n-1;i++){ for(j=0;j<n;j++){ m[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); } } for(k=0;k<n*(n-1)/2;k++){ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(max<m[i][j]){ max=m[i][j]; b=i; c=j; } } } if(max==0){break;} else{ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[b],y[b],z[b],x[c],y[c],z[c],max); m[b][c]=0; max=0; } } return 0; }
64
31,827
int main( ){ int i,n,k,t,q=0; int x[10],y[10],z[10],a[50],b[50]; double s[50],ss[50],j; scanf("%d\n",&n); for(i=0;i<n;i++){ scanf("%d %d %d ",&(x[i]),&(y[i]),&(z[i])); } for(t=0;t<n-1;t++){ for(i=t+1;i<n;i++){ s[q]=1.0*(x[t]-x[i])*(x[t]-x[i])+1.0*(y[t]-y[i])*(y[t]-y[i])+1.0*(z[t]-z[i])*(z[t]-z[i]); ss[q]=sqrt(s[q]); a[q]=t; b[q]=i; q++; } } for(k=1;k<=q;k++){ for(i=0;i<q-k;i++){ if(ss[i]<ss[i+1]){ j=ss[i+1]; ss[i+1]=ss[i]; ss[i]=j; j=a[i+1]; a[i+1]=a[i]; a[i]=j; j=b[i+1]; b[i+1]=b[i]; b[i]=j; } } } for(i=0;i<q;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],ss[i]); } return 0; }
64
31,828
int main (){ int n; cin>>n; int x[10],y[10],z[10]; int i,j; for(i=0;i<=n-1;i++) cin>>x[i]>>y[i]>>z[i];//??i??????? float d[45];//?? int s[45],e[45];//???????? int t=0;//??d??? for(i=0;i<=n-2;i++) for(j=i+1;j<=n-1;j++)//??????????????????????????????????????????????????????????? { d[t]=sqrt((x[i]-x[j])*(x[i]-x[j])+ (y[i]-y[j])*(y[i]-y[j])+ (z[i]-z[j])*(z[i]-z[j])); s[t]=i,e[t]=j; t++; } float tempd; int temp; for(i=0;i<=t-2;i++) for(j=t-1;j>=i+1;j--) if(d[j]>d[j-1]) { tempd=d[j],d[j]=d[j-1],d[j-1]=tempd; temp=s[j],s[j]=s[j-1],s[j-1]=temp; temp=e[j],e[j]=e[j-1],e[j-1]=temp; } cout<<fixed<<setprecision(2);//?????? for(i=0;i<=t-1;i++) cout<<"("<<x[s[i]]<<","<<y[s[i]]<<","<<z[s[i]]<<")-("<<x[e[i]]<<","<<y[e[i]]<<","<<z[e[i]]<<")="<<d[i]<<endl; }
64
31,829
double a[10000],g[10000]; void mppx(double a[],int n); int main() { int n,i,j,k,l,v,w; double d,e,f; struct b{ double x,y,z; }c[1000]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%lf%lf%lf",&(c[i].x),&(c[i].y),&(c[i].z)); } j=0; k=1; for(i=0;i<(n-1)*n/2;i++){ d=(c[j].x-c[k].x)*(c[j].x-c[k].x); e=(c[j].y-c[k].y)*(c[j].y-c[k].y); f=(c[j].z-c[k].z)*(c[j].z-c[k].z); if(e<0){ e=-e; } if(f<0){ f=-f; } if(d<0){ d=-d; } a[i]=d+e+f; a[i]=sqrt(a[i]); k++; if(k==n){ j++; k=j+1; } } mppx(a,n*(n-1)/2); l=0; v=n-1; for(i=0;i<(n-1)*n/2;i++){ for(j=0;j<(n-1)*n/2;j++){ if(a[j]==g[i]){ for(w=j;w>=v;j=j){ if(w>=v){ l++; w=w-v+l; } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",(int)(c[l].x),(int)(c[l].y),(int)(c[l].z),(int)(c[w+1].x),(int)(c[w+1].y),(int)(c[w+1].z),g[i]); a[j]=0; l=0; break; } } } return 0; } void mppx(double a[],int n){ int i,j; double t; for(i=0;i<n;i++){ g[i]=a[i]; } for(i=0;i<n-1;i++){ for(j=n-2;j>=0;j--){ if(g[j]<g[j+1]){ t=g[j]; g[j]=g[j+1]; g[j+1]=t; } } } }
64
31,830
int main () { int a[10][3] = {0}; //???????? int n = 0; //??n?????? cin >> n; int i = 0, j = 0, k = 0; //???????? for ( i = 0; i < n; i ++ ) //?????? for ( j = 0; j < 3; j ++ ) cin >> a[i][j]; double distance[100] = {0}; //??????????? double dis = 0; //????? for ( i = 0; i < n; i ++ ) //?????? for ( j = i + 1; j < n; j ++ ) { for ( k = 0; k < 3; k ++ ) dis = dis + (a[i][k]-a[j][k])*(a[i][k]-a[j][k]); distance[i*10+j] = sqrt(dis); dis = 0; } int b[100] = {0}; //???????????? for ( i = 0; i < 100; i ++ ) b[i] = i; for ( i = 0; i < 99; i ++ ) //????? for ( j = 0; j < 99 - i; j ++ ) { if ( distance[j] < distance[j+1] ) { swap ( distance[j], distance[j+1] ); swap ( b[j], b[j+1] ); } } for ( i = 0; i < n*(n-1)/2; i ++ ) //???????????? { cout << "(" << a[b[i]/10][0] << "," << a[b[i]/10][1] << "," << a[b[i]/10][2] << ")-("; cout << a[b[i]%10][0] << "," << a[b[i]%10][1] << "," << a[b[i]%10][2] << ")="; printf ( "%.2f", distance[i] ); cout << endl; } return 0; }
64
31,831
struct DIS { int fir; int sec; double d; }; int main() { struct DIS dis[50]; const double eps=1e-6; int x[11]; int y[11]; int z[11]; int n,i,j,k=1; struct DIS temp; cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { dis[k].fir=i; dis[k].sec=j; dis[k++].d=sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); } } for(i=1;i<=n*(n-1)/2;i++) { for(j=n*(n-1)/2;j>=i+1;j--) { if(dis[j].d>dis[j-1].d+eps) { temp.d=dis[j].d; temp.fir=dis[j].fir; temp.sec=dis[j].sec; dis[j].d=dis[j-1].d; dis[j].fir=dis[j-1].fir; dis[j].sec=dis[j-1].sec; dis[j-1].d=temp.d; dis[j-1].fir=temp.fir; dis[j-1].sec=temp.sec; } } } for(i=1;i<=n*(n-1)/2;i++) { cout<<"("<<x[dis[i].fir]<<","<<y[dis[i].fir]<<","<<z[dis[i].fir]<<")-("<<x[dis[i].sec]<<","<<y[dis[i].sec]<<","<<z[dis[i].sec]<<")="<<fixed<<setprecision(2)<<dis[i].d<<endl; } return 0; }
64
31,832
int main() { int n,i,j,k=0,l; double B[10][10],a,C[91]={0},A[10][3]; cin>>n; for (i=0;i<n;i++) cin>>A[i][0]>>A[i][1]>>A[i][2]; for (i=0;i<n-1;i++) { for (j=i+1;j<n;j++) { B[i][j]=sqrt((A[i][0]-A[j][0])*(A[i][0]-A[j][0])+(A[i][1]-A[j][1])*(A[i][1]-A[j][1])+(A[i][2]-A[j][2])*(A[i][2]-A[j][2])); C[k]=B[i][j]; k=k+1; } } for (i=0;i<n*(n-1)/2;i++) { for (j=0;j<n*(n-1)/2-1;j++) { if (C[j]<C[j+1]) { a=C[j]; C[j]=C[j+1]; C[j+1]=a; } } } for (i=0;i<n*(n-1)/2;i++) { for (k=0;k<n-1;k++) { for (l=k+1;l<n;l++) { if (B[k][l]==C[i]) { cout<<fixed<<setprecision(0)<<"("<<A[k][0]<<","<<A[k][1]<<","<<A[k][2]<<")"<<"-"<<"("<<A[l][0]<<","<<A[l][1]<<","<<A[l][2]<<")"<<"="; cout<<fixed<<setprecision(2)<<B[k][l]<<endl; B[k][l]=0; } } } } return 0; }
64
31,833
void main() { int n,i,m,j,k=0; double d,b[100][7]={0},a[10][3]={0},temp[7]; char c[10][3]; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) { scanf("%lf",&a[i][j]); scanf("%c",&c[i][j]); } } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])); b[k][0]=a[i][0]; b[k][1]=a[i][1]; b[k][2]=a[i][2]; b[k][3]=a[j][0]; b[k][4]=a[j][1]; b[k][5]=a[j][2]; b[k][6]=d; k++; } } for(i=0;i<n*(n-1)/2;i++) { for(j=i+1;j<n*(n-1)/2;j++) { if(b[j][6]>b[i][6]) { for(k=0;k<7;k++) { temp[k]=b[j][k]; } for(m=j;m>i;m--) { for(k=0;k<7;k++) { b[m][k]=b[m-1][k]; } } for(k=0;k<7;k++) { b[i][k]=temp[k]; } } } } for(i=0;i<n*(n-1)/2;i++) printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",b[i][0],b[i][1],b[i][2],b[i][3],b[i][4],b[i][5],b[i][6]); }
64
31,834
int main() { int n,i,j,k=0; double d[10][10]={0},D[45]={0},t; struct point {int x; int y; int z; }p[10]; scanf("%d",&n); for(i=0;i<n;i++) {scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z);} for(i=0;i<n-1;i++) {for(j=i+1;j<n;j++) {d[i][j]=sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y)+(p[i].z-p[j].z)*(p[i].z-p[j].z)); D[k]=d[i][j]; k++;}} for(i=0;i<n*(n-1)/2-1;i++) {for(j=0;j<n*(n-1)/2-i-1;j++) {if(D[j]<D[j+1]) {t=D[j]; D[j]=D[j+1]; D[j+1]=t;}}} for(k=0;k<n*(n-1)/2;k++) {if(D[k]==D[k+1]) continue; else {for(i=0;i<n-1;i++) {for(j=i+1;j<n;j++) if(d[i][j]==D[k]) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",p[i].x,p[i].y,p[i].z,p[j].x,p[j].y,p[j].z,d[i][j]);}}}} return 0; }
64
31,835
int main(){ int a1[100],a2[100],a3[100],n,z[100],i,j,k=0,a[100],b[100]; double o,m,x[100],y[100]; scanf("%d\n",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a1[i],&a2[i],&a3[i]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ x[k]=(a1[i]-a1[j])*(a1[i]-a1[j])+(a2[i]-a2[j])*(a2[i]-a2[j])+(a3[i]-a3[j])*(a3[i]-a3[j]); y[k]=sqrt(x[k]); a[k]=i; b[k]=j; k=k+1; } } for(i=1;i<=k;i++){ for(j=0;j<k-i;j++){ if(y[j]<y[j+1]){ m=y[j]; y[j]=y[j+1]; y[j+1]=m; m=a[j]; a[j]=a[j+1]; a[j+1]=m; m=b[j]; b[j]=b[j+1]; b[j+1]=m; } } } for(i=0;i<k;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a1[a[i]],a2[a[i]],a3[a[i]],a1[b[i]],a2[b[i]],a3[b[i]],y[i]); } }
64
31,836
int main() { int geshu; cin>>geshu; int i,j,xh; double a[11][4]={0}; double b[11][11]={0}; for(i=1;i<=geshu;i++)cin>>a[i][1]>>a[i][2]>>a[i][3]; for(i=1;i<geshu;i++) { for(j=i+1;j<=geshu;j++) { double m; m=(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3]); b[i][j]=sqrt(m); } } int jiayou; jiayou=geshu*(geshu-1)/2; for(xh=jiayou;xh>=1;xh--) { for(i=1;i<geshu;i++)//??????b????????,????.?????????????,????t???,T??n*(n-1)/2??????? { for(j=i+1;j<=geshu;j++)//??????b[i][j],?????t??xh { int p,q,t; t=0; for(p=1;p<geshu;p++) { for(q=p+1;q<=geshu;q++) { if(b[i][j]>=b[p][q])t++; } } if(t==xh) { cout<<"("<<a[i][1]<<","<<a[i][2]<<","<<a[i][3]<<")-("<<a[j][1]<<","<<a[j][2]<<","<<a[j][3]<<")="; printf("%0.2f",b[i][j]); cout<<endl; } } } } return 0; }
64
31,837
typedef struct point { int x,y,z; }POINT; typedef struct disdence { POINT a,b; double dst; }PD; double Squ(double num) { return num * num; } double Distance(POINT a,POINT b) { return sqrt(Squ(a.x - b.x) + Squ(a.y - b.y) + Squ(a.z - b.z)); } int main() { POINT pt[10]; PD tmp,dst[45]; int i,j,k,n,N; //printf("???? : "); scanf("%d",&n); if(n > 10) n = 10; N = n*(n - 1)/2; for(i = 0;i < n;i++) { //printf("?%d : ",i + 1); scanf("%d %d %d",&pt[i].x,&pt[i].y,&pt[i].z); } k = 0; for(i = 0;i < n - 1;i++) { /*???????*/ for(j = i + 1;j < n;j++) { dst[k].a = pt[i]; dst[k].b = pt[j]; dst[k].dst = Distance(pt[i],pt[j]); k++; } } for(i = 0;i < N- 1;i++) for(j = 0;j < N -i -1;j++ ) if(dst[j].dst < dst[j + 1].dst){ tmp = dst[j]; dst[j] = dst[j +1]; dst[j + 1] = tmp; } //cout << N << endl; /* for(i = 0;i < N - 1;i++) {//????????? k = i; for(j = i + 1;j < N;j++) { if(dst[k].dst <= dst[j].dst) k = j; } if(k != i) { tmp = dst[k]; dst[k] = dst[i]; dst[i] = tmp; } }*/ for(i = 0; i < N; i++) { printf("(%d,%d,%d)-",dst[i].a.x,dst[i].a.y,dst[i].a.z); printf("(%d,%d,%d)=",dst[i].b.x,dst[i].b.y,dst[i].b.z); printf("%.2lf\n",dst[i].dst); } return 0; }
64
31,838
/* * shuzu.2.3.cpp * * Created on: 2012-11-19 * Author: wangrunhui */ int main() { int n,a[10][3],i,j,k ,ai[100],ak[100],l = 0,tempi,tempk;//a?????i,j,k,l???????ai?ak?????????? double d[100],tempd;//d???? cin >> n; for ( i = 0; i < n; i ++)//?a?? { for ( j = 0; j < 3; j ++) cin >> a[i][j]; } for ( i = 0; i < n; i ++)//???????????????????? { for ( k = i + 1; k < n; k ++ )//???i+1????????????? { d[l] = sqrt( (a[i][0] - a[k][0]) * (a[i][0] - a[k][0]) + (a[i][1] - a[k][1]) * (a[i][1] - a[k][1]) + (a[i][2] - a[k][2]) * (a[i][2] - a[k][2]) ); ai[l] = i;//?????? ak[l] = k; l ++;//????????? } } for ( i = 0 ; i < l - 1; i ++)//???????????????????????????? { for ( j = 0; j < l - i - 1; j ++) { if ( d[j] < d[j + 1]) { tempd = d[j]; d[j] = d[j + 1]; d[j + 1] = tempd; tempi = ai[j]; ai[j] = ai[j + 1]; ai[j + 1] = tempi; tempk = ak[j]; ak[j] = ak[j + 1]; ak[j + 1] = tempk; } } } for ( j = 0; j < l ; j ++)//?????? { i = ai[j]; k = ak[j]; cout << '(' << a[i][0] << ','<< a[i][1] << ',' << a[i][2] << ")-("; cout << a[k][0] << ',' << a[k][1] << ',' << a[k][2]<< ")="; cout<< fixed << setprecision(2) <<d[j]<<endl;//??????? } }
64
31,839
struct point1 { int x; int y; int z; } point[10]; struct comb1 { struct point1 po1; struct point1 po2; double distant; } comb[50],t; int abs(int a) { if(a>=0) return a; else return(-a); } double dis(struct point1 a,struct point1 b) { int p,q,r; double ans; p=(a.x-b.x)*(a.x-b.x); q=(a.y-b.y)*(a.y-b.y); r=(a.z-b.z)*(a.z-b.z); ans=sqrt(p+q+r); return ans; } int main() { int n,i,j,k; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].z); k=0; for(i=0;i<n;i++) for(j=i+1;j<n;j++) { comb[k].po1=point[i]; comb[k].po2=point[j]; comb[k].distant=dis(comb[k].po1,comb[k].po2); k++; } for(i=1;i<k;i++) for(j=0;j<k-i;j++) if(comb[j].distant<comb[j+1].distant) { t=comb[j]; comb[j]=comb[j+1]; comb[j+1]=t; } for(i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",comb[i].po1.x,comb[i].po1.y,comb[i].po1.z,comb[i].po2.x,comb[i].po2.y,comb[i].po2.z,comb[i].distant); //scanf("%d",&i); return 0; }
64
31,840
int main(){ int m,n,i,h=1,l=0,k,j,x[11],y[11],z[11],N; double s[50],p,d[50],t; scanf("%d",&n); N=(((n-1)*n)/2); /*???N?*/ for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ /*???????????????*/ s[l]=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]));/*????sl*/ l++;/*?????s[l]*/ } } for(l=0;l<N;l++){/*??????sl????????*/ m=l; for(j=l+1;j<N;j++){ if (s[m]<s[j]){ p=s[j]; s[j]=s[m]; s[m]=p; } } } d[0]=s[0],j=1;/*????????j-1?????d[0]??*/ for(l=1;l<N;l++){/*?????????sl???????????*/ if(d[j-1]!=s[l]){ d[j]=s[l]; j++; h++; } } for (j=0;j<h;j++){/*??????d[j]??*/ for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ t=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k])); if(d[j]==t){/*??d[j]???x[i],x[k]??????*/ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[k],y[k],z[k],d[j]); } } } } return 0; }
64
31,841
int main() { int n; scanf("%d",&n); double x[150],y[150],z[150]; int i; for(i=1;i<=n;i++) { scanf("%lf",&x[i]); scanf("%lf",&y[i]); scanf("%lf",&z[i]); } int j,h; h=1; double sum; double s1[150][150]; double a[10000]; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { sum=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); s1[i][j]=sqrt(sum); a[h]=s1[i][j]; h++; } } h--; int k; double e; for(k=1;k<h;k++) { for(i=1;i<=h-k;i++) { if(a[i]<a[i+1]) { e=a[i]; a[i]=a[i+1]; a[i+1]=e; } } } int count=2; double b[10000]; b[1]=a[1]; for(i=2;i<=h;i++) { if(a[i]!=a[i-1]) { b[count]=a[i]; count++; } } count--; for(k=1;k<=count;k++) { for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { if(s1[i][j]==b[k]) printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],b[k]); } } } return 0; }
64
31,842
typedef struct _DISTANCE{ float distance; int pointa[3]; int pointb[3]; } DISTANCE; int main() { int n,i,j,k=0,b,m,point[10][3]; cin>>n; for(i=0;i<n;i++){ for(j=0;j<3;j++){ cin>>point[i][j]; } } DISTANCE test[n*(n-1)/2]; for ( i = 0; i <n; ++i) { for(j=i+1;j<n;j++) { float distance=sqrt((point[i][0]-point[j][0])*(point[i][0]-point[j][0])+(point[i][1]-point[j][1])*(point[i][1]-point[j][1])+(point[i][2]-point[j][2])*(point[i][2]-point[j][2])); test[k].distance=distance; for(m=0;m<3;m++) test[k].pointa[m]=point[i][m]; for(m=0;m<3;m++) test[k].pointb[m]=point[j][m]; k++; } } for ( i = 0; i <n*(n-1)/2-1 ; i++) { for(j = 0; j <n*(n-1)/2-i-1 ; j++) { if(test[j].distance<test[j+1].distance) { DISTANCE temp=test[j+1]; test[j+1]=test[j] ; test[j]=temp; } } } for(k=0;k<n*(n-1)/2;k++) { cout<<"("<<test[k].pointa[0]<<","<<test[k].pointa[1]<<"," <<test[k].pointa[2]<<")"<<"-"<<"("<<test[k].pointb[0]<<","<<test[k].pointb[1]<<"," <<test[k].pointb[2]<<")"<<"="; printf("%.2f\n",test[k].distance); } }
64
31,843
int main() { int n; struct dian { float a; int x; int y; }a[45]; struct dian t; int d[10][3]; int i,j,k=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&d[i][0],&d[i][1],&d[i][2]); } for(i=1;i<n;i++) { for(j=0;j<i;j++) { a[k].a=sqrt((d[i][0]-d[j][0])*(d[i][0]-d[j][0])+(d[i][1]-d[j][1])*(d[i][1]-d[j][1])+(d[i][2]-d[j][2])*(d[i][2]-d[j][2])); a[k].x=j; a[k].y=i; k++; } } for(i=0;i<k-1;i++) { for(j=0;j<k-1-i;j++) { if(a[j].a<a[j+1].a) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",d[a[i].x][0],d[a[i].x][1],d[a[i].x][2],d[a[i].y][0],d[a[i].y][1],d[a[i].y][2],a[i].a); } return 0; }
64
31,844
int main () { int n,a[4][10],p; //?? float dis[100][3]; float fuzhu; cin >>n; //?? for (int i=0;i<n;i++) { for (int j=1;j<=3;j++) { cin >>a[j][i]; } } p=0; for (int i=0;i<n;i++) //?? { for (int j=i+1;j<n;j++) { p++; dis[p][0]=sqrt((float)((a[1][i]-a[1][j])*(a[1][i]-a[1][j])+(a[2][i]-a[2][j])*(a[2][i]-a[2][j])+(a[3][i]-a[3][j])*(a[3][i]-a[3][j]))); dis[p][1]=i; dis[p][2]=j; } } for (int i=1;i<=1000;i++) //?? { for (int j=1;j<=p-1;j++) { if (dis[j][0]<dis[j+1][0]) { fuzhu=dis[j][0];dis[j][0]=dis[j+1][0];dis[j+1][0]=fuzhu; fuzhu=dis[j][1];dis[j][1]=dis[j+1][1];dis[j+1][1]=fuzhu; fuzhu=dis[j][2];dis[j][2]=dis[j+1][2];dis[j+1][2]=fuzhu; } } } for (int i=1;i<=p;i++) //?? { cout <<"("<<a[1][(int)dis[i][1]]<<","<<a[2][(int)dis[i][1]]<<","<<a[3][(int)dis[i][1]]<<")-("<<a[1][(int)dis[i][2]]<<","<<a[2][(int)dis[i][2]]<<","<<a[3][(int)dis[i][2]]<<")="; cout <<fixed<<setprecision(2)<<dis[i][0]; cout <<endl; } return 0; }
64
31,845
//**************************************** //*???? ** //*??? 1100012927 ** //*2011.11.29 ** //**************************************** int main() { int n, i, j, k, z = 0; double dis[50][7], zb[10][3], temp; double (*p)[7]; p = dis; cin >> n; for (i = 0; i < n; i++) { cin >> zb[i][0] >> zb[i][1] >> zb[i][2]; } for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) { for (k = 0; k < 3; k++) { *(*(p + z) + k) = zb[i][k]; *(*(p + z) + k + 3) = zb[j][k]; } *(*(p + z) + 6) = sqrt(pow((*(*(p + z) + 0) - *(*(p + z) + 3)), 2) + pow((*(*(p + z) + 1) - *(*(p + z) + 4)), 2) + pow((*(*(p + z) + 2)- *(*(p + z) + 5)), 2)); z++; } for (i = 0; i < z - 1; i++) for (j = 0; j < z - i - 1; j++) { if (fabs(*(*(p + j) + 6) - *(*(p + j + 1) + 6)) < 1e-3) continue; else if (*(*(p + j) + 6) < *(*(p + j + 1) + 6)) { for (k = 0; k < 7; k++) { temp = *(*(p + j) + k); *(*(p + j) + k) = *(*(p + j + 1) + k); *(*(p + j + 1) + k) = temp; } } } for (i = 0; i < n * (n - 1) / 2; i++) { cout << fixed; cout <<setprecision(0)<< "(" << *(*(p + i) + 0) <<","<< *(*(p + i) + 1) <<"," << *(*(p + i) + 2) <<")-("<< *(*(p + i) + 3) <<","<<*(*(p + i) + 4)<<","<<*(*(p + i) + 5)<<")="; cout << setprecision(2) << *(*(p + i) + 6)<<endl; } return 0; }
64
31,846
// // main.cpp // ???? // // Created by ? ?? on 12-12-11. // Copyright (c) 2012? ? ??. All rights reserved. // int main() { double b[99999][6]; double c[99999]; double a[1000][3]; int n; cin >> n; int i, j, k = 0, m; for (i = 0; i < n; i++) { for (j = 0; j < 3; j++) { cin >> a[i][j]; } } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { b[k][0] = a[i][0];b[k][1] = a[i][1];b[k][2] = a[i][2];b[k][3] = a[j][0];b[k][4] = a[j][1];b[k][5] = a[j][2]; c[k] = sqrt(pow(a[j][0] - a[i][0], 2) + pow(a[j][1] - a[i][1], 2) + pow(a[j][2] - a[i][2], 2)); k++; } } for (i = 0; i < k - 1; i++) { for (j = 0; j < k - 1 - i; j++) { if (c[j] < c[j + 1]) { double p = c[j]; c[j] = c[j + 1]; c[j + 1] = p; for (m = 0; m < 6; m++) { p = b[j][m]; b[j][m] = b[j+1][m]; b[j+1][m] = p; } } } } for (i = 0; i < k; i++) { cout << fixed << setprecision(0) << "(" << b[i][0] << "," << b[i][1] << "," << b[i][2] << ")" << "-" << "(" << b[i][3] << "," << b[i][4] << "," << b[i][5] << ")" << "=" << fixed << setprecision(2) << c[i] << endl; } return 0; }
64
31,847
int main(){ struct dian{ int x,y,z; }dians[45]; struct suoyou{ struct dian qian; struct dian hou; double ji; }suoyous[45],e; int n; scanf("%d",&n); int i; for(i=0;i<n;i++){ scanf("%d%d%d",&dians[i].x,&dians[i].y,&dians[i].z); } int k,l=0; for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ suoyous[l].qian=dians[i]; suoyous[l].hou=dians[k]; suoyous[l].ji=sqrt((dians[i].x-dians[k].x)*(dians[i].x-dians[k].x)+(dians[i].y-dians[k].y)*(dians[i].y-dians[k].y)+(dians[i].z-dians[k].z)*(dians[i].z-dians[k].z)); l++; } } for(i=1;i<=n*(n-1)/2;i++){ for(k=0;k<n*(n-1)/2-i;k++){ if(suoyous[k].ji<suoyous[k+1].ji){ e=suoyous[k]; suoyous[k]=suoyous[k+1]; suoyous[k+1]=e; } } } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",suoyous[i].qian.x,suoyous[i].qian.y,suoyous[i].qian.z,suoyous[i].hou.x,suoyous[i].hou.y,suoyous[i].hou.z,suoyous[i].ji); } return 0; }
64
31,848
float dis(int a[3],int b[3]) { float d=0; for (int i=0;i<3;i++) d+=(a[i]-b[i])*(a[i]-b[i]); d=pow(d,0.5); return d; } int main() { int n,x=0,y; scanf("%d",&n); int a[n][3]; y=n*(n-1)/2; float b[y][3],m[3]; for (int i=0;i<n;i++) for (int j=0;j<3;j++) scanf("%d",&a[i][j]); for (int i=0;i<n-1;i++) for (int j=i+1;j<n;j++) { b[x][0]=i; b[x][1]=j; b[x][2]=dis(a[i],a[j]); x++; } for (int j=y-2;j>=0;j--) for (int i=0;i<=j;i++) if (b[i][2]<b[i+1][2]) for (int k=0;k<3;k++) { m[k]=b[i][k]; b[i][k]=b[i+1][k]; b[i+1][k]=m[k]; } for (int i=0;i<y;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[(int)b[i][0]][0],a[(int)b[i][0]][1],a[(int)b[i][0]][2],a[(int)b[i][1]][0],a[(int)b[i][1]][1],a[(int)b[i][1]][2],b[i][2]); }
64
31,849
int main(){ int x[10],y[10],z[10],n,i,j,k=0; struct{ double d; int nu1,nu2; }p[50],zh; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(j=0;j<n-1;j++){ for(i=j+1;i<n;i++){ p[k].d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); p[k].nu1=j; p[k].nu2=i; k++; } } for(i=0;i<k-1;i++){ for(j=0;j<k-1-i;j++){ if(p[j].d>p[j+1].d){ zh=p[j+1]; p[j+1]=p[j]; p[j]=zh; } else if(p[j].d==p[j+1].d){ if(p[j].nu1<p[j+1].nu1){ zh=p[j+1]; p[j+1]=p[j]; p[j]=zh; } else if((p[j].nu1==p[j+1].nu1)&&(p[j].nu2<p[j+1].nu2)){ zh=p[j+1]; p[j+1]=p[j]; p[j]=zh; } } } } for(i=k-1;i>=0;i--){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p[i].nu1],y[p[i].nu1],z[p[i].nu1],x[p[i].nu2],y[p[i].nu2],z[p[i].nu2],p[i].d); } return 0; }
64
31,850
int main() { int n; //??n cin>>n; //??n float a[100],b[100],c[100],s[100],t; //??????a,b,c,???????????t int i,l,m,p=0,j,k,q,x,d[100],e[100]; //???????????d,e for(i=0;i<n;i++) { cin>>a[i]>>b[i]>>c[i]; //???? } for(l=0;l<n-1;l++) { for(m=l+1;m<n;m++) { s[p]=sqrt((a[l]-a[m])*(a[l]-a[m])+(b[l]-b[m])*(b[l]-b[m])+(c[l]-c[m])*(c[l]-c[m])); //???? d[p]=l; //??????????? e[p]=m; p++; } } for(j=0;j<p-1;j++) { for(k=j+1;k<p;k++) { if(s[k]>s[j]) //???????? { t=s[k]; s[k]=s[j]; s[j]=t; q=d[k]; d[k]=d[j]; //??????? d[j]=q; q=e[k]; e[k]=e[j]; e[j]=q; } if(s[k]==s[j]) { if(d[j]>d[k]||e[j]>e[k]) //?????????????????? { q=d[k]; d[k]=d[j]; d[j]=q; q=e[k]; e[k]=e[j]; e[j]=q; } } } } for(x=0;x<p;x++) { cout<<"("<<a[d[x]]<<","<<b[d[x]]<<","<<c[d[x]]<<")-("<<a[e[x]]<<","<<b[e[x]]<<","<<c[e[x]]<<")="; printf("%.2f\n",s[x]); //?? } return 0; }
64
31,851
int main(){ int n,a[100][100],i,j,k,p,l,m=0,x,c[100][100],d[100][100],e2,e3,o,w=0; double b[100],e1; scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&a[i][j]); } } for(p=1;p<=n;p++){ for(k=p-1;k<n-1;k++){ for(j=0;j<3;j++){ x=a[p-1][j]-a[k+1][j]; m=m+x*x; c[w][j]=a[p-1][j]; d[w][j]=a[k+1][j]; } b[w]=sqrt(m); w++; m=0; } } o=n*(n-1)/2; for(l=1;l<=o;l++){ for(k=0;k<o-l;k++){ if(b[k]<b[k+1]){ for(j=0;j<3;j++){ e1=b[k]; e2=c[k][j]; e3=d[k][j]; b[k]=b[k+1]; c[k][j]=c[k+1][j]; d[k][j]=d[k+1][j]; b[k+1]=e1; c[k+1][j]=e2; d[k+1][j]=e3; } } } } for(k=0;k<o;k++){ printf("("); printf("%d,%d,%d",c[k][0],c[k][1],c[k][2]); printf(")-("); printf("%d,%d,%d",d[k][0],d[k][1],d[k][2]); printf(")="); printf("%.2lf\n",b[k]); } return 0; }
64
31,852
int main(){ int a[10][3]; int x,y,z,i,j,k,n,f=0; scanf("%d",&n); double tmp,result[45][3]; for(i=0;i<n;i++){ scanf("%d%d%d",&x,&y,&z); a[i][0]=x;a[i][1]=y;a[i][2]=z; } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ result[f][0]=sqrt(pow(a[i][0]-a[j][0],2)+pow(a[i][1]-a[j][1],2)+pow(a[i][2]-a[j][2],2)); result[f][1]=i; result[f][2]=j; f=f+1; } } for(i = 0; i < f; i++){ for(j = f-1; j >i-1; j--){ if(result[j][0] < result[j+1][0]){ for(k=0;k<3;k++){ tmp = result[j+1][k]; result[j+1][k] = result[j][k]; result[j][k] = tmp; }} } } for(i=0;i<f;i++){ printf("(%d,%d,%d)-",a[(int)result[i][1]][0],a[(int)result[i][1]][1],a[(int)result[i][1]][2]); printf("(%d,%d,%d)=",a[(int)result[i][2]][0],a[(int)result[i][2]][1],a[(int)result[i][2]][2]); printf("%.2f\n",result[i][0]); } return 0; }
64
31,853
int main() { int n,i,j,a[10000],b[10000],m,x[100],y[100],z[100]; float dis[10000],t; cin>>n; for (i=1; i<=n; i++) cin>>x[i]>>y[i]>>z[i]; int cnt=0; for (i=1; i<=n; i++) for (j=i+1; j<=n; j++) { dis[cnt]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); a[cnt]=i; b[cnt]=j; cnt=cnt+1; } for (i=0; i<cnt-1; i++) for(j=0; j<cnt-1-i; j++) if(dis[j]<dis[j+1]){ t=dis[j]; dis[j]=dis[j+1]; dis[j+1]=t; m=a[j]; a[j]=a[j+1]; a[j+1]=m; m=b[j]; b[j]=b[j+1]; b[j+1]=m; } for(i=0; i<cnt; i++) cout<<fixed<<setprecision(2)<<"("<<x[a[i]]<<","<<y[a[i]]<<","<<z[a[i]]<<")-("<<x[b[i]]<<","<<y[b[i]]<<","<<z[b[i]]<<")="<<dis[i]<<endl; return 0; }
64
31,854
int main() //????? { double a[11][4],b[46][7]; //????:a[i][k]?i????j????b[][]??????? double c[46],p; //c[]??????????????p int i,j,k=0,n; //????n,????i,j,k cin>>n; for(i=1;i<=n;i++) //?????? { for(j=1;j<=3;j++) { cin>>a[i][j]; } } for(i=1;i<=n-1;i++) //????????????? { for(j=i+1;j<=n;j++) { k++; c[k]=sqrt((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3])); b[k][1]=a[i][1]; b[k][2]=a[i][2]; b[k][3]=a[i][3]; b[k][4]=a[j][1]; b[k][5]=a[j][2]; b[k][6]=a[j][3]; } } for(i=1;i<=k-1;i++) //????????????????? { for(j=1;j<=k-i;j++) { if(c[j]<c[j+1]) { p=c[j]; c[j]=c[j+1]; c[j+1]=p; p=b[j][1]; b[j][1]=b[j+1][1]; b[j+1][1]=p; p=b[j][2]; b[j][2]=b[j+1][2]; b[j+1][2]=p; p=b[j][3]; b[j][3]=b[j+1][3]; b[j+1][3]=p; p=b[j][4]; b[j][4]=b[j+1][4]; b[j+1][4]=p; p=b[j][5]; b[j][5]=b[j+1][5]; b[j+1][5]=p; p=b[j][6]; b[j][6]=b[j+1][6]; b[j+1][6]=p; } } } for(i=1;i<=k;i++) //???????????????????? printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",(int)b[i][1],(int)b[i][2],(int)b[i][3],(int)b[i][4],(int)b[i][5],(int)b[i][6],c[i]); return 0; }
64
31,855
int main(){ int n,a,m,js=0,p=0,q,e; scanf("%d\n",&n); int x[n-1],y[n-1],z[n-1]; double jg[100],o; for(int i=0;i<100;i++){ jg[i]=-1; } for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(int i=0;i<n-1;i++){ for(int k=i+1;k<n;k++){ a=10*i+k; jg[a]=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k])); } } o=0; m=n*(n-1)/2; for(int i=0;i<100;i++){ if(js==m){ break; } if(o<jg[i]){ o=jg[i]; p=i; } if(i==99){ q=p/10; n=p-q*10; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[q],y[q],z[q],x[n],y[n],z[n],o); jg[p]=-1; i=-1; o=0; js++; } } return 0; }
64
31,856
int main(){ int shu[10][3],i,j,n,a; double d[1000],e; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&shu[i][0],&shu[i][1],&shu[i][2]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ d[10*i+j]=0; } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=(shu[i][0]-shu[j][0])*(shu[i][0]-shu[j][0])+(shu[i][1]-shu[j][1])*(shu[i][1]-shu[j][1])+(shu[i][2]-shu[j][2])*(shu[i][2]-shu[j][2]); d[10*i+j]=sqrt(a); } } while(1){ e=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(d[10*i+j]>e){ e=d[10*i+j]; } } } if(e==0){ break; } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(d[10*i+j]==e){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",shu[i][0],shu[i][1],shu[i][2],shu[j][0],shu[j][1],shu[j][2],e); d[10*i+j]=0; }}} } return 0; }
64
31,857
int main() { int n,i,j,k; double x,y,z; int a[10][3]={0};; double b[45]={0}; int c[45]={0},d[45]={0}; cin>> n; for(i=0;i<n;i++) { cin>> a[i][0] >> a[i][1] >> a[i][2]; } k=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { x=y=z=0; x=(a[i][0]-a[j][0])*(a[i][0]-a[j][0]); y=(a[i][1]-a[j][1])*(a[i][1]-a[j][1]); z=(a[i][2]-a[j][2])*(a[i][2]-a[j][2]); b[k]=sqrt(x+y+z);c[k]=i;d[k]=j; k++; } } for(i=0;i<n*(n-1)/2-1;i++) { for(j=0;j<n*(n-1)/2-i-1;j++) { if(b[j]<b[j+1]) { x=b[j];b[j]=b[j+1];b[j+1]=x; k=c[j];c[j]=c[j+1];c[j+1]=k; k=d[j];d[j]=d[j+1];d[j+1]=k; } } } for(i=0;i<n*(n-1)/2;i++) { cout<<"("<<a[c[i]][0]<<","<<a[c[i]][1]<<","<<a[c[i]][2]<<")-("<<a[d[i]][0]<<","<<a[d[i]][1]<<","<<a[d[i]][2]<<")="; printf("%.2f",b[i]);cout<<endl; } return 0; }
64
31,858
int main(){ int n,i,j,k=0,z; int a[10][3]; scanf("%d",&n); for(i=0;i<n;i++){ if(i==0){ scanf("%d %d %d",&a[0][0],&a[0][1],&a[0][2]); } else{ scanf(" %d %d %d",&a[i][0],&a[i][1],&a[i][2]);} } struct { int b[3],c[3]; float d; }x[46]; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ x[k].b[0]=a[i][0]; x[k].b[1]=a[i][1]; x[k].b[2]=a[i][2]; x[k].c[0]=a[j][0]; x[k].c[1]=a[j][1]; x[k].c[2]=a[j][2]; x[k].d=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])); k++; } } for(i=0;i<k;i++){ for(j=k-1;j>i;j--){ if(x[j].d>x[j-1].d){ x[45]=x[j]; x[j]=x[j-1]; x[j-1]=x[45]; } } } for(i=0;i<k;i++){ printf("\n(%d,%d,%d)-(%d,%d,%d)=%.2f",x[i].b[0],x[i].b[1],x[i].b[2],x[i].c[0],x[i].c[1],x[i].c[2],x[i].d); } return 0;}
64
31,859
void main() { int n,m,a[11][3],i,j,k,l; double b[46][3],s,t; scanf("%d",&n); m=n*(n-1)/2; for(i=0;i<n;i++) { scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]); } i=0; for(j=0;j<n-1;j++) { for(k=j+1;k<=n-1;k++) { s=sqrt((a[j][0]-a[k][0])*(a[j][0]-a[k][0])+(a[j][1]-a[k][1])*(a[j][1]-a[k][1])+(a[j][2]-a[k][2])*(a[j][2]-a[k][2])); b[i][0]=j; b[i][1]=k; b[i][2]=s; i++; } } for(i=m-1;i>0;i--) { for(j=0;j<i;j++) { if(b[j][2]<b[j+1][2]) { for(l=0;l<=2;l++) { t=b[j+1][l]; b[j+1][l]=b[j][l]; b[j][l]=t; } } else if(fabs(b[j][2]-b[j+1][2])<1e-6&&b[j][0]>b[j+1][0]) { for(l=0;l<=2;l++) { t=b[j+1][l]; b[j+1][l]=b[j][l]; b[j][l]=t; } } else if(fabs(b[j][2]-b[j+1][2])<1e-6&&b[j][0]==b[j+1][0]&&b[j][1]>b[j+1][1]) { for(l=0;l<=2;l++) { t=b[j+1][l]; b[j+1][l]=b[j][l]; b[j][l]=t; } } } } for(i=0;i<m;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[(int)b[i][0]][0],a[(int)b[i][0]][1],a[(int)b[i][0]][2],a[(int)b[i][1]][0],a[(int)b[i][1]][1],a[(int)b[i][1]][2],b[i][2]); } }
64
31,860
int main() { int sz1[100],sz2[100],sz3[100],n,i,j,k=0,r,a[100],b[100]; double q[10][10],p[10][10],temp,m[72]; scanf("%d",&n); for(i=0;i<=n-1;i++) { scanf("%d%d%d",&sz1[i],&sz2[i],&sz3[i]); } for(i=0;i<=n-1;i++) { for(j=i+1;j<=n-1;j++) { q[i][j]=1.0*((sz1[i]-sz1[j])*(sz1[i]-sz1[j])+(sz2[i]-sz2[j])*(sz2[i]-sz2[j])+(sz3[i]-sz3[j])*(sz3[i]-sz3[j])); p[i][j]=sqrt(q[i][j]); m[k]=p[i][j]; a[k]=i; b[k]=j; k=k+1; } } for(r=0;r<(n*(n-1)/2);r++) { for(k=0;k<=n*(n-1)/2-2;k++) { if(m[k]<m[k+1]) { temp=m[k]; m[k]=m[k+1]; m[k+1]=temp; temp=a[k]; a[k]=a[k+1]; a[k+1]=temp; temp=b[k]; b[k]=b[k+1]; b[k+1]=temp; } } } for(k=0;k<(n*(n-1))/2;k++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz1[a[k]],sz2[a[k]],sz3[a[k]],sz1[b[k]],sz2[b[k]],sz3[b[k]],m[k]); } return 0; }
64
31,861
int t[2000]; double id(int a,int b,int c) { return sqrt(a*a+b*b+c*c); } int main() { int i,j,n,m,s=0,x[20],y[20],z[20],q[200],w[200]; double d[200]; scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d%d%d",&x[i],&y[i],&z[i]); } n=m*(m-1)/2; for(i=0;i<m-1;i++) for(j=i+1;j<m;j++) { d[s]=id(x[i]-x[j],y[i]-y[j],z[i]-z[j]); q[s]=i; w[s]=j; s++; } //for(i=0;i<=n+1;i++) //{for(j=0;j<=n+1;j++)printf("%d ",a[i][j]);printf("\n");} for(i=1;i<=n;i++) for(j=0;j<n-i;j++) if(d[j]<d[j+1]) { swap(q[j],q[j+1]); swap(w[j],w[j+1]); swap(d[j],d[j+1]); } for(j=0;j<n;j++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[q[j]],y[q[j]],z[q[j]],x[w[j]],y[w[j]],z[w[j]],d[j]); return 0; }
64
31,862
int main() { int n,i,j,t,g,f,m,k; int a[10],b[10],c[10],z[50][6]; double s[50],e; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&(a[i]),&(b[i]),&(c[i])); } t=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { s[t]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[j]-c[i])*(c[j]-c[i])); z[t][0]=a[i];z[t][1]=b[i];z[t][2]=c[i];z[t][3]=a[j];z[t][4]=b[j];z[t][5]=c[j]; t++; } } e=0;k=0; for(i=1;i<=t;i++) { for(j=0;j<t-i;j++) { if(s[j]<s[j+1]) { e=s[j+1]; s[j+1]=s[j]; s[j]=e; for(m=0;m<6;m++) { k=z[j+1][m]; z[j+1][m]=z[j][m]; z[j][m]=k; } } } } for(g=0;g<t;g++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",z[g][0],z[g][1],z[g][2],z[g][3],z[g][4],z[g][5],s[g]); } return 0; }
64
31,863
void main() { int n,i,j,k,y,z; int a[10],b[10],c[10],p[45],q[45]; float m[45],x,t; scanf("%d",&n); for (i=0;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); k=0; for (i=0;i<n-1;i++) { for (j=i+1;j<n;j++) { x=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]); p[k]=i; q[k]=j; m[k]=sqrt(x); k++; } } for (i=k-1;i>=0;i--) { for (j=k-1;j>=k-i-1;j--) { if (m[j+1]>m[j]) { t=m[j]; m[j]=m[j+1]; m[j+1]=t; y=p[j]; p[j]=p[j+1]; p[j+1]=y; z=q[j]; q[j]=q[j+1]; q[j+1]=z; } } } for (i=0;i<k;i++) { y=p[i]; z=q[i]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[y],b[y],c[y],a[z],b[z],c[z],m[i]); } }
64
31,864
double h(int x1,int y1,int z1,int x2,int y2,int z2) { double s; int x,y,z; x=x1-x2; y=y1-y2; z=z1-z2; s=sqrt(x*x+y*y+z*z); return s; } int main() { int n,a[10],b[10],c[10]; int i,k,j; struct shizi{ int x1;int x2; int y1;int y2; int z1;int z2; double l; } s[50],tmp; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i],&b[i],&c[i]); } k=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { s[k].x1=a[i]; s[k].x2=a[j]; s[k].y1=b[i]; s[k].y2=b[j]; s[k].z1=c[i]; s[k].z2=c[j]; s[k].l=h(a[i],b[i],c[i],a[j],b[j],c[j]); k++; } } for(i=1;i<=k;i++) { for(j=0;j<k-1;j++) { if(s[j].l<s[j+1].l) { tmp=s[j]; s[j]=s[j+1]; s[j+1]=tmp; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",s[i].x1,s[i].y1,s[i].z1,s[i].x2,s[i].y2,s[i].z2,s[i].l); } return 0; }
64
31,865
void main() { int n,a[10][3],b[45][2],i,j,k=0,t; float c[45],s; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i][0]); scanf("%d",&a[i][1]); scanf("%d",&a[i][2]); } for(i=0;i<n;i++) for(j=i+1;j<n;j++) { b[k][0]=i; b[k][1]=j; c[k]=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])); k++; } for(j=0;j<k-1;j++) for(i=0;i<k-1-j;i++) { if(c[i]<c[i+1]) { s=c[i]; c[i]=c[i+1]; c[i+1]=s; t=b[i][0]; b[i][0]=b[i+1][0]; b[i+1][0]=t; t=b[i][1]; b[i][1]=b[i+1][1]; b[i+1][1]=t; } } for(i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[b[i][0]][0],a[b[i][0]][1],a[b[i][0]][2],a[b[i][1]][0],a[b[i][1]][1],a[b[i][1]][2],c[i]); }
64
31,866
/* * Name:distance.cpp * * Created on: 2012-11-05 * Author: ?? * Function????? */ int main() { int n, i, j, count, temp=0; float sum; cin >> n; count=n*(n-1)/2; int point[3][n]; float distance[count]; float distance_temp; int ptp[2][count], ptp_temp; for (i=0;i<n;i++){ for (j=0;j<3;j++){ cin >> point[j][i]; } } for (i=0;i<n-1;i++){ for (j=i+1;j<n;j++){ sum=(float)(point[0][i]-point[0][j])*(point[0][i]-point[0][j])+(point[1][i]-point[1][j])*(point[1][i]-point[1][j])+(point[2][i]-point[2][j])*(point[2][i]-point[2][j]); distance[temp]=sqrt(sum); ptp[0][temp]=i; ptp[1][temp]=j; temp++; } } for (i=0;i<count-1;i++){ for (j=0;j<count-1-i;j++){ if (distance[j]<distance[j+1]){ distance_temp=distance[j]; distance[j]=distance[j+1]; distance[j+1]=distance_temp; ptp_temp=ptp[0][j+1]; ptp[0][j+1]=ptp[0][j]; ptp[0][j]=ptp_temp; ptp_temp=ptp[1][j+1]; ptp[1][j+1]=ptp[1][j]; ptp[1][j]=ptp_temp; } } } for (i=0;i<count;i++){ cout << '(' << point[0][ptp[0][i]] << ',' << point[1][ptp[0][i]] << ',' << point[2][ptp[0][i]] << ")-("; cout << point[0][ptp[1][i]] << ',' << point[1][ptp[1][i]] << ',' << point[2][ptp[1][i]] << ")="; cout << fixed << setprecision(2) << distance[i] << endl; } return 0; }
64
31,867
struct position { int x; int y; int z; }pos[10]; int main() { int n, finish[10][10] = {0}, cnt = 0; float d[10][10] = {0}, square = 0, max = 0; cin >> n; for (int i = 0; i < n; i++) cin >> pos[i].x >> pos[i].y >> pos[i].z; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { square = (pos[i].x - pos[j].x) * (pos[i].x - pos[j].x) + (pos[i].y - pos[j].y) * (pos[i].y - pos[j].y) + (pos[i].z - pos[j].z) * (pos[i].z - pos[j].z); d[i][j] = sqrt(square); } } for (int k = 0; k < n * (n - 1) / 2; k++, max = 0) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (max < d[i][j] && finish[i][j] == 0) max = d[i][j]; } } for (int p = 0; p < n; p++) { for (int q = 0; q < n; q++) { if (max == d[p][q]) { finish[p][q] = 1; cnt++; cout << "(" << pos[p].x << ',' << pos[p].y << ',' << pos[p].z << ")-(" << pos[q].x << ',' << pos[q].y << ',' << pos[q].z << ")=" << fixed << setprecision(2) << d[p][q] << endl; } } } if (cnt == n * (n - 1) / 2) break; } return 0; }
64
31,868
struct zuhe { int a[3]; int b[3]; double m; }; int main() { struct zuhe z[50]; struct zuhe b; int l,i,j,n,m,k=0; int s[100][4]; scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<3;j++) scanf("%d",&s[i][j]); } for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ for(l=0;l<3;l++){ z[k].a[l]=s[i][l]; z[k].b[l]=s[j][l]; } z[k].m=pow((s[i][0]-s[j][0])*(s[i][0]-s[j][0])+(s[i][1]-s[j][1])*(s[i][1]-s[j][1])+(s[i][2]-s[j][2])*(s[i][2]-s[j][2]),0.5); k=k+1; } } for(i=1;i<n*(n-1)/2;i++){ for(j=0;j<n*(n-1)/2-i;j++){ if(z[j].m<z[j+1].m){ b=z[j]; z[j]=z[j+1]; z[j+1]=b; } } } for(i=0;i<n*(n-1)/2;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",z[i].a[0],z[i].a[1],z[i].a[2],z[i].b[0],z[i].b[1],z[i].b[2],z[i].m); return 0; }
64
31,869
int main(){ int i,a,b,c=1,p,q,n,M[46],N[46],e; double x[11],y[11],z[11],l[46],d; scanf("%d ",&n); for(i=1;i<=n;i++){ scanf("%lf %lf %lf",&x[i],&y[i],&z[i]); } for(a=1;a<n;a++){ for(b=a+1;b<=n;b++){ l[c]=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])+(z[a]-z[b])*(z[a]-z[b])); M[c]=a; N[c]=b; c++; } } for(p=1;p<(n*(n-1))/2;p++){ for(q=p+1;q<=(n*(n-1));q++){ if(l[p]<l[q]){ for(i=q;i>p;i--){ d=l[i]; l[i]=l[i-1]; l[i-1]=d; e=M[i]; M[i]=M[i-1]; M[i-1]=e; e=N[i]; N[i]=N[i-1]; N[i-1]=e; } } } } for(i=1;i<=n*(n-1)/2;i++){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[M[i]],y[M[i]],z[M[i]],x[N[i]],y[N[i]],z[N[i]],l[i]); } return 0; }
64
31,870
//********************** //* ??? ???? * //* 1200012878 ??? * //* 12?15? * //********************** struct dian { int a; int b; int c; } p[10]; // ?????????? struct len { int s; int m; double dis; } q[45]; // ????????????? int main() { int n, count = -1, i, j, k, temp1, temp2; double temp3; cin >> n; for (i = 0; i < n; i++) cin >> p[i].a >> p[i].b >> p[i].c; // ??????? for (j = 0; j < n - 1; j++) { for (k = j + 1; k < n; k++) { count++; q[count].dis = sqrt((p[j].a - p[k].a) * (p[j].a - p[k].a) + (p[j].b - p[k].b) * (p[j].b - p[k].b) + (p[j].c - p[k].c) * (p[j].c - p[k].c)); q[count].s = j; q[count].m = k; } } // ?????????? for(i = 0; i < count; i++) { for (j = count - 1; j >= i; j--) { if (q[j].dis < q[j + 1].dis) { temp1 = q[j].s; temp2 = q[j].m; temp3 = q[j].dis; q[j].s = q[j + 1].s; q[j].m = q[j + 1].m; q[j].dis = q[j + 1].dis; q[j + 1].s = temp1; q[j + 1].m = temp2; q[j + 1].dis = temp3; } } } // ?????????????????????????????????? for (i = 0; i <= count; i++) cout << "(" << p[q[i].s].a << "," << p[q[i].s].b << "," << p[q[i].s].c << ")" << "-" << "(" << p[q[i].m].a << "," << p[q[i].m].b << "," << p[q[i].m].c << ")" << "=" << setprecision(2) << fixed << q[i].dis << endl; // ????? return 0; }
64
31,871
int main(){ int n,i,j,N,k,t; int a[11][4],b[50][7]; double d[50],e; scanf("%d",&n); N=n*(n-1)/2; for(i=1;i<=n;i++){ for(j=1;j<=3;j++){ scanf("%d",&a[i][j]); } } t=1; for(i=1;i<n;i++){ for(j=i+1;j<=n;j++){ b[t][3]=a[i][3]; b[t][1]=a[i][1]; b[t][2]=a[i][2]; b[t][6]=a[j][3]; b[t][4]=a[j][1]; b[t][5]=a[j][2]; t++; } } for(t=1;t<=N;t++){ d[t]=sqrt((b[t][3]-b[t][6])*(b[t][3]-b[t][6])+(b[t][1]-b[t][4])*(b[t][1]-b[t][4])+(b[t][2]-b[t][5])*(b[t][2]-b[t][5])); } for(k=N;k>0;k--){ for(i=1;i<k;i++){ if(d[i]<d[i+1]){ e=d[i]; d[i]=d[i+1]; d[i+1]=e; for(j=1;j<=6;j++){ e=b[i][j]; b[i][j]=b[i+1][j]; b[i+1][j]=e; } } } } for(i=1;i<=N;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i][1],b[i][2],b[i][3],b[i][4],b[i][5],b[i][6],d[i]); } return 0; }
64
31,872
int main() { int n, i, j, k, m = 0; double taoyan[100]; struct ss { int x; int y; int z; double jl[10]; }zz[10]; cin >> n; for(int i = 0; i < n; ++i) cin >> zz[i].x >> zz[i].y >> zz[i].z; for(i = 0; i < n - 1; i++) for(j = i + 1; j < n; j++) { int a = (zz[i].x - zz[j].x) * (zz[i].x - zz[j].x) + (zz[i].y - zz[j].y) * (zz[i].y - zz[j].y) + (zz[i].z - zz[j].z) * (zz[i].z - zz[j].z); zz[i].jl[j] = sqrt(a); taoyan[m ++] = zz[i].jl[j]; } sort(taoyan, taoyan + m); for(k = m ; k >= 0; k--) { for(i = 0; i < n - 1; ++i) for(j = i + 1; j < n; ++j) { if(zz[i].jl[j] == taoyan[k]) { cout << "(" << zz[i].x << "," << zz[i].y << "," << zz[i].z << ")-(" << zz[j].x << "," << zz[j].y << "," << zz[j].z << ")=" << fixed << setprecision(2) << zz[i].jl[j] << endl; zz[i].jl[j] = 0; } } } return 0; }
64
31,873
void main() { float max,s[11][11],z[11][3]; int i,j,n,x,y,k; scanf("%d",&n); memset(s,0,sizeof(s)); memset(z,0,sizeof(z)); for (i=1;i<=n;i++) { scanf("%f%f%f",&z[i][0],&z[i][1],&z[i][2]); for (j=1;j<i;j++) { s[j][i]=sqrt((z[i][0]-z[j][0])*(z[i][0]-z[j][0])+(z[i][1]-z[j][1])*(z[i][1]-z[j][1])+(z[i][2]-z[j][2])*(z[i][2]-z[j][2])); } } for (i=1;i<=n*(n-1)/2;i++) { max=s[1][2]; x=1;y=2; for (j=1;j<n;j++) for (k=j+1;k<=n;k++) { if (s[j][k]>max) { x=j;y=k; max=s[j][k]; //printf("%.2f\n",max); } } printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",z[x][0],z[x][1],z[x][2],z[y][0],z[y][1],z[y][2],s[x][y]); s[x][y]=0; } }
64
31,874
int main(){ int n; int x[1000],y[1000],z[1000],a[100],b[100] ; double s[1000],c[1000]; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]);} int t=0; for(int i=0;i<n;i++){ for(int k=i+1;k<n;k++){ s[t]=(x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]); a[t]=i; b[t]=k; t++;}} double e; int r; for(int i=0;i<t-1;i++){ for(int k=0;k<t-i-1;k++){ if(s[k]<s[k+1]){ e=s[k+1]; s[k+1]=s[k]; s[k]=e; r=a[k+1];a[k+1]=a[k];a[k]=r;r=b[k+1];b[k+1]=b[k];b[k]=r; } }} for(int i=0;i<t;i++){ c[i]=1.0*sqrt(s[i]);} for(int i=0;i<t;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],c[i]);} return 0; }
64
31,875
//******************** //**??????? ** //**????? ** //**???2013.12.15** //**????4.cpp ** //******************** int main() { int n, i, j, cnt= 0, p[10][3]; double sum; struct distance // ?????????????? { int x1; int y1; int z1; int x2; int y2; int z2; double dist; }group[45], temp; cin >> n; for (i = 0; i < n; i++) cin >> p[i][0] >> p[i][1] >> p[i][2]; // ?????? for (i = 0; i < n - 1; i++) for (j = 1; j < n - i; j++) { group[cnt].x1 = p[i][0]; group[cnt].y1 = p[i][1]; group[cnt].z1 = p[i][2]; group[cnt].x2 = p[i + j][0]; group[cnt].y2 = p[i + j][1]; group[cnt].z2 = p[i + j][2]; sum = (p[i][0] - p[i + j][0]) * (p[i][0] - p[i + j][0]) + (p[i][1] - p[i + j][1]) * (p[i][1] - p[i + j][1]) + (p[i][2] - p[i + j][2]) * (p[i][2] - p[i + j][2]); group[cnt].dist = sqrt(sum); // ???????????????????? cnt++; } for (i = 0; i < n * (n - 1) / 2 - 1; i++) for (j = 0; j < n * (n - 1) / 2 - 1 - i; j++) if (group[j].dist < group[j + 1].dist) // ??????????????? { temp = group[j]; group[j] = group[j + 1]; group[j + 1] = temp; } for (i = 0; i < n * (n - 1) / 2; i++) { cout << '(' << group[i].x1 << ',' << group[i].y1 << ',' << group[i].z1 << ')' << '-' << '(' << group[i].x2 << ',' << group[i].y2 << ',' << group[i].z2 << ')' << '='; printf("%.2f", group[i].dist); // ?????????????? cout << endl; } return 0; }
64
31,876
int main(){ int n,b=0,i; scanf("%d",&n); int x[10],y[10],z[10],k; double len[10][10],num[100],s; for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ len[i][k]=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k])); num[b]=len[i][k]; b++; } } for(k=1;k<=b;k++){ for(i=0;i<(b-k);i++){ if(num[i]>num[i+1]){ s=num[i+1]; num[i+1]=num[i]; num[i]=s; } } } for(b;b>=0;b--){ for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ if(num[b]==len[i][k]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[k],y[k],z[k],len[i][k]); break; } } if(num[b]==len[i][k]){ len[i][k]=10000000; break; } } } return 0; }
64
31,877
/** * @file 1.cpp * @author ??? * @date 2011-12?07 * @description * ??????:???? */ int main() { int n, d[101][3]; int i, j, k, m1, m2; int (*p)[3]; p = d; double l[10][10], max = 0; cin >> n; for (i = 0; i < n; i++) { cin >>*(*(p + i)) >> *(*(p + i) + 1) >> *(*(p + i) + 2); // ??i?????? } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { l[i][j] = sqrt((double)(*(*(p + i)) - *(*(p + j))) * (*(*(p + i)) - *(*(p + j))) + (*(*(p + i) + 1) - *(*(p + j) + 1)) * (*(*(p + i) + 1) - *(*(p + j) + 1)) + (*(*(p + i) + 2) - *(*(p + j) + 2)) * (*(*(p + i) + 2) - *(*(p + j) + 2))); } // ???????? } for (k = 0; k < n * (n - 1) / 2; k++) { for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (l[i][j] > max) { max = l[i][j]; m1 = i; m2 = j; // ????????? } } } cout << '(' << *(*(p + m1)) << ',' << *(*(p + m1) + 1) << ',' << *(*(p + m1) + 2) << ")-("; cout << *(*(p + m2)) << ',' << *(*(p + m2) + 1) << ',' << *(*(p + m2) + 2) << ')' << '=' ; cout << fixed << setprecision(2) << l[m1][m2] << endl; l[m1][m2] = 0; // ?????????????????????? max = 0; } return 0; }
64
31,878
int x[20], y[20], z[20],p[1100]; int main() { int i, n, j, plen; for (plen = 0, scanf("%d", &n), i = n - 1; i >= 0; i--) { scanf("%d%d%d", &x[i], &y[i], &z[i]); for (j = n - 1; j > i; j--, plen++) p[plen] = ((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j])+ (z[i] - z[j]) * (z[i] - z[j])) * 1000 + i * 20 + j; } for (i=0;i<plen;i++){ for (j=i+1;j<plen;j++) if (p[i]<p[j]){ n=p[i]; p[i]=p[j]; p[j]=n; } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", x[p[i]%20],y[p[i]%20],z[p[i]%20], x[(p[i]%1000)/20],y[(p[i]%1000)/20],z[(p[i]%1000)/20],sqrt(p[i]/1000)); } }
64
31,879
/** * @file homework.cpp * @author ??? * @date 2011-12-06 * @description * ??????: ?????? */ struct juli { int a; int b; double dis; }x[45],t; int main() { int n,m=0; int i,j,k,p=0,l,s,r; int a[10][3]={0}; cin>>n; for(i=0;i<n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; } m=n*n/2-n/2; for(j=0;j<n-1;j++) { for(k=j+1;k<n;k++) { if(k>j) { x[p].a=j; x[p].b=k; x[p].dis=sqrt((a[j][0]-a[k][0])*(a[j][0]-a[k][0]) +(a[j][1]-a[k][1])*(a[j][1]-a[k][1]) +(a[j][2]-a[k][2])*(a[j][2]-a[k][2])); p++; } } } for(l=0;l<m-1;l++) { for(s=0;s<m-l-1;s++) { if(x[s].dis<x[s+1].dis) { t=x[s]; x[s]=x[s+1]; x[s+1]=t; } } } for(r=0;r<m;r++) { cout<<"("<<a[x[r].a][0]<<","<<a[x[r].a][1]<<","<<a[x[r].a][2]<<")-(" <<a[x[r].b][0]<<","<<a[x[r].b][1]<<","<<a[x[r].b][2]<<")=" <<fixed<<setprecision(2)<<x[r].dis<<endl; } return 0; }
64
31,880
int main() { struct point { int x; int y; int z; }Point[10]; int n,i,j,k=0,f[45],b[45],temp; double d[45],num; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&Point[i].x,&Point[i].y,&Point[i].z); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d[k]=sqrt((Point[i].x-Point[j].x)*(Point[i].x-Point[j].x)+(Point[i].y-Point[j].y)*(Point[i].y-Point[j].y)+(Point[i].z-Point[j].z)*(Point[i].z-Point[j].z)); f[k]=i; b[k]=j; k=k+1; } } for(i=0;i<k;i++) { for(j=0;j<k-i;j++) { if(d[j]<d[j+1]) { temp=f[j]; f[j]=f[j+1]; f[j+1]=temp; temp=b[j]; b[j]=b[j+1]; b[j+1]=temp; num=d[j]; d[j]=d[j+1]; d[j+1]=num; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",Point[f[i]].x,Point[f[i]].y,Point[f[i]].z,Point[b[i]].x,Point[b[i]].y,Point[b[i]].z,d[i]); } return 0; }
64
31,881
int main(){ int zb[100][3],a,n,j,k,i; double b,jl[100],t; scanf("%d",&n); for( i=0;i<n;i++){ for(k=0;k<3;k++){ scanf("%d",&zb[i][k]); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ jl[10*i+j]=0; } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=((zb[i][0]-zb[j][0])*(zb[i][0]-zb[j][0]))+((zb[i][1]-zb[j][1])*(zb[i][1]-zb[j][1]))+((zb[i][2]-zb[j][2])*(zb[i][2]-zb[j][2])); jl[10*i+j]=sqrt(a); } } while(1){ t=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(jl[10*i+j]>t){ t=jl[10*i+j]; } } } if(t==0){ break; } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(jl[10*i+j]==t){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",zb[i][0],zb[i][1],zb[i][2],zb[j][0],zb[j][1],zb[j][2],t); jl[10*i+j]=0; } } } } return 0; }
64
31,882
double juli(int a,int b,int c,int d,int e,int f) { int x,y,z; double sum; x=d-a; y=e-b; z=f-c; sum=x*x+y*y+z*z; sum=sqrt(sum); return sum; } int main() { int n,i,j; int sz[10][3]; double distance[45][9]; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) { scanf("%d",&sz[i][j]); } sz[i][3]=i; } int r=0,k; for(i=0;i<n;i++) { if(i<n-1) { for(j=i+1;j<n;j++) { distance[r][0]=sz[i][0]; distance[r][1]=sz[i][1]; distance[r][2]=sz[i][2]; distance[r][3]=sz[i][3]; distance[r][4]=sz[j][0]; distance[r][5]=sz[j][1]; distance[r][6]=sz[j][2]; distance[r][7]=sz[j][3]; distance[r][8]=juli(sz[i][0],sz[i][1],sz[i][2],sz[j][0],sz[j][1],sz[j][2]); r++; } } } for(i=0;i<r;i++) { for(j=0;j<r-i;j++) { double c[10]; if(distance[j][8]<distance[j+1][8]) { for(k=0;k<9;k++) { c[k]=distance[j][k]; } for(k=0;k<9;k++) { distance[j][k]=distance[j+1][k]; } for(k=0;k<9;k++) { distance[j+1][k]=c[k]; } //*c=*distance[j]; //*distance[j]=*distance[j+1]; //*distance[j+1]=*c; } } } for(i=0;i<r;i++) { printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",distance[i][0],distance[i][1],distance[i][2],distance[i][4],distance[i][5],distance[i][6],distance[i][8]); } return 0; }
64
31,883
int main() { int n,m,i,j,x,y,t=0; cin>>n; int a[10],b[10],c[10],e[100]; double d[100]; for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) {e[t]=10*i+j; d[e[t]]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); t++; } for(i=1;i<t;i++) for(j=0;j<t-i;j++) {if(d[e[j]]<d[e[j+1]]) { m=e[j]; e[j]=e[j+1]; e[j+1]=m; }} for(i=0;i<t;i++) {x=e[i]%10; y=(e[i]-x)/10; cout<<"("<<a[y]<<","<<b[y]<<","<<c[y]<<")-("<<a[x]<<","<<b[x]<<","<<c[x]<<")="<<fixed<<setprecision(2)<<d[e[i]]<<endl; } return 0; }
64
31,884
int main(){ int n; int x[10],y[10],z[10], q=0,a[100],b[100],c[100],d[100],e[100],f[100]; float t,m[100]; scanf("%d",&n); for(int h=0;h<n;h++){ scanf("%d%d%d",&x[h],&y[h],&z[h]); } for(int i=0;i<n;i++){ for(int u=i+1;u<n;u++){ m[q] =(float)sqrt((x[i]-x[u])*(x[i]-x[u])+(y[i]-y[u])*(y[i]-y[u])+(z[i]-z[u])*(z[i]-z[u])); a[q]=x[i];b[q]=y[i];c[q]=z[i];d[q]=x[u];e[q]=y[u];f[q]=z[u]; q++; } } for(int r=0;r<q;r++){ for(int k=0;k<q-r;k++){ if(m[k]<m[k+1]){ t=m[k+1]; m[k+1]=m[k]; m[k]=t; t=a[k+1]; a[k+1]=a[k]; a[k]=t; t=b[k+1]; b[k+1]=b[k]; b[k]=t; t=c[k+1]; c[k+1]=c[k]; c[k]=t; t=d[k+1]; d[k+1]=d[k]; d[k]=t; t=e[k+1]; e[k+1]=e[k]; e[k]=t; t=f[k+1]; f[k+1]=f[k]; f[k]=t; } } } for(int w=0;w<q;w++) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[w],b[w],c[w],d[w],e[w],f[w],m[w]);} return 0; }
64
31,885
int main() { int n,i,j,t,q,s;//n??????i,j??????t??????????q,s????????????? cin>>n;//??n t=n*(n-1)/2;//??t int x[n+1],y[n+1],z[n+1],a[t+1],b[t+1];//???????a[n+1],b[n+1]?????????????? float dis[t+1],p;//???p????? for(i=1;i<=n;i++)//????????? { cin>>x[i]>>y[i]>>z[i]; } for(i=1;i<=n-1;i++)//??????????????????????? { for(j=i+1;j<=n;j++) { dis[(2*n-i)*(i-1)/2+j-i]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); a[(2*n-i)*(i-1)/2+j-i]=i; b[(2*n-i)*(i-1)/2+j-i]=j; } } for(j=1;j<=t;j++)//???? { for(i=1;i<=t;i++) { if(dis[i]<dis[i+1]) { p=dis[i]; dis[i]=dis[i+1]; dis[i+1]=p; q=a[i]; a[i]=a[i+1]; a[i+1]=q; s=b[i]; b[i]=b[i+1]; b[i+1]=s; } } } for(i=1;i<=t;i++)//???? { cout<<"("<<x[a[i]]<<","<<y[a[i]]<<","<<z[a[i]]<<")-("<<x[b[i]]<<","<<y[b[i]]<<","<<z[b[i]]<<")="<<fixed<<setprecision(2)<<dis[i]<<endl; } return 0; }
64
31,886
struct point{ int x; int y; int z;}; struct dis{ float distance; struct point d1; struct point d2;}; int main() { void bubble(struct dis b[100],int len); float fun(struct point pt1,struct point pt2); int n,m,num,i,up,w; struct dis a[100]={0,0,0}; struct point pt[10]={0,0,0}; scanf("%d",&num); for(i=0;i<num;i++) { scanf("%d%d%d",&pt[i].x,&pt[i].y,&pt[i].z); } //printf("%d%d%d",pt[1].x,pt[2].x,pt[3].x); w=num*(num-1)/2; for(i=0;i<w;) { for(n=0;n<num-1;n++) { for(m=n+1;m<num;m++) { a[i].distance=fun(pt[n],pt[m]); a[i].d1.x=pt[n].x; //printf("%d",a[i].d1.x); a[i].d1.y=pt[n].y; a[i].d1.z=pt[n].z; a[i].d2.x=pt[m].x; a[i].d2.y=pt[m].y; a[i].d2.z=pt[m].z; i++; } } } up=i; //printf("%d",up); //printf("%d%d",a[1].d1.x,a[1].d1.y); bubble(a,up); for(i=0;i<up;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%3.2f\n",a[i].d1.x,a[i].d1.y,a[i].d1.z,a[i].d2.x,a[i].d2.y,a[i].d2.z,a[i].distance); } return 0; } float fun(struct point p1,struct point p2) { float result,mid; mid=(p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z); result=sqrt(mid); return(result); } void bubble(struct dis b[100],int len) { int i,pass; struct dis temp;//temp???????????? for(pass=1;pass<len;pass++) { for(i=0;i<len-pass;i++) { if(b[i].distance<b[i+1].distance) {temp=b[i];b[i]=b[i+1];b[i+1]=temp;} } } }
64
31,887
typedef struct { int x,y,z; } Point; typedef struct { double len; int pt1,pt2; } Distance; double CalDis(Point pt1,Point pt2) { return sqrt((double)(pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y)+(pt1.z-pt2.z)*(pt1.z-pt2.z)); } int cmp( const void *a ,const void *b) { if((*(Distance *)a).len != (*(Distance *)b).len) return (*(Distance *)a).len > (*(Distance *)b).len ? -1 : 1; //return ((Distance *)b)->len - ((Distance *)a)->len; //return (*(Distance *)a).pt1 > (*(Distance *)b).pt1 ? 1 : -1; if(((Distance *)a)->pt1 != ((Distance *)b)->pt1) return ((Distance *)a)->pt1 - ((Distance *)b)->pt1; return ((Distance *)a)->pt2 - ((Distance *)b)->pt2; } /*int cmp( const void *a ,const void *b) { if((*(Distance *)b).len != (*(Distance *)a).len) return (*(Distance *)b).len > (*(Distance *)a).len ? 1 : -1; else return (*(Distance *)a).pt1 > (*(Distance *)b).pt1 ? 1 : -1; }*/ Distance ds[N]; int main() { int n,count=0,i,j; Point pts[10]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d %d %d",&pts[i].x,&pts[i].y,&pts[i].z); for(i=0;i<n;i++) for(j=i+1;j<n;j++) { ds[count].len=CalDis(pts[i],pts[j]); ds[count].pt1=i; ds[count++].pt2=j; } qsort(ds,count,sizeof(ds[0]),cmp); for(i=0;i<count;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",pts[ds[i].pt1].x,pts[ds[i].pt1].y, pts[ds[i].pt1].z,pts[ds[i].pt2].x,pts[ds[i].pt2].y,pts[ds[i].pt2].z,ds[i].len); return 0; }
64
31,888
/* *????04.cpp *?????? *?????2011-12-15 *???????????n??????10??,??n?????????,??????????????????????????? */ int main() { int n; //????????? cin>>n; struct zb //????????????? { int x; int y; int z; }dian[n]; for(int i=0;i<n;i++) //???? cin>>dian[i].x>>dian[i].y>>dian[i].z; double distance[n][n]; //???????? for(int i=0;i<n;i++) for(int j=0;j<n;j++) distance[i][j]=0.0; for(int i=0;i<n-1;i++) //????????? for(int j=i+1;j<n;j++) distance[i][j]=(sqrt)((dian[i].x-dian[j].x)*(dian[i].x-dian[j].x)+(dian[i].y-dian[j].y)*(dian[i].y-dian[j].y)+(dian[i].z-dian[j].z)*(dian[i].z-dian[j].z)); int amount=n*(n-1)/2; for(int i=0;i<amount;i++) //?????????? { double maxdis=0; int maxX=0,maxY=0; for(int j=0;j<n-1;j++) //?????????????????? { for(int k=j+1;k<n;k++) { if(maxdis<distance[j][k]) { maxdis=distance[j][k]; maxX=j; maxY=k; } } } cout<<"("<<dian[maxX].x<<","<<dian[maxX].y<<","<<dian[maxX].z<<")"<<"-"<<"("<<dian[maxY].x<<","<<dian[maxY].y<<","<<dian[maxY].z<<")"<<"="; cout<<fixed<<setprecision(2)<<maxdis<<endl; distance[maxX][maxY]=0.0; } return 0; }
64
31,889
struct coordinate { int x; int y; int z; } point[10]; int main() { double dis[10][10]={0}, d[100]={0}, temp=0; int i, j, n, k1=0, k2=0, k; cin>>n; for(i=0; i<n; i++) { cin>>point[i].x>>point[i].y>>point[i].z; } for(i=0; i<n-1; i++) { for(j=i+1; j<n; j++) { dis[i][j]=sqrt((point[i].x-point[j].x)*(point[i].x-point[j].x)+(point[i].y-point[j].y)*(point[i].y-point[j].y)+(point[i].z-point[j].z)*(point[i].z-point[j].z)) ; d[10*i+j]=sqrt((point[i].x-point[j].x)*(point[i].x-point[j].x)+(point[i].y-point[j].y)*(point[i].y-point[j].y)+(point[i].z-point[j].z)*(point[i].z-point[j].z)) ; } } for(i=0; i<99; i++) { for(j=99; j>i; j--) { if(d[j]>d[j-1]) { temp=d[j]; d[j]=d[j-1]; d[j-1]=temp; } } } for(i=99; i>=1; i--) { if(d[i]==d[i-1]) { d[i]=0; } } for(k=0; k<99; k++) { if(d[k]!=0) { for(i=0; i<n-1; i++) { for(j=i+1; j<n; j++) { if(dis[i][j]==d[k]) { cout<<"("<<point[i].x<<","<<point[i].y<<","<<point[i].z<<")-("<< point[j].x<<","<<point[j].y<<","<<point[j].z<<")="<<fixed<<setprecision(2)<<dis[i][j]<<endl; } } } } } return 0; }
64
31,890
struct District { int x; int y; int z; }dis[11];//???? struct Distance { int a; int b; double c; }d[91],temp;//????????? int main() { int n,k=1; cin>>n; for(int i=1;i<=n;i++) { cin>>dis[i].x>>dis[i].y>>dis[i].z; } for(int i=1;i<n;i++) { for(int j=i+1;j<=n;j++) { d[k].a=i; d[k].b=j; d[k].c=sqrt((double)(dis[i].x-dis[j].x)*(dis[i].x-dis[j].x)+(dis[i].y-dis[j].y)*(dis[i].y-dis[j].y)+(dis[i].z-dis[j].z)*(dis[i].z-dis[j].z)); k++; } }//?i????j????? for(int i=1;i<=k-2;i++) { for(int j=1;j<=k-i;j++) { if(d[j].c<d[j+1].c) { temp=d[j]; d[j]=d[j+1]; d[j+1]=temp; } } }//?????? for(int i=1;i<=k-1;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dis[d[i].a].x,dis[d[i].a].y,dis[d[i].a].z,dis[d[i].b].x,dis[d[i].b].y,dis[d[i].b].z,d[i].c); }//?? return 0; }
64
31,891
int main() //????? { int n; //???? cin>>n; //???? double a[20][4]={0}; //????a???n???? double dis[50]; //????????????????? int u[50],v[50],l = 1; //????u,v?????????? for(int i = 1 ; i <= n ; i++) //??n?????? { for(int j = 1 ; j <= 3 ; j++) { cin>>a[i][j]; } } for(int i = 1 ; i < n ; i++) //??????????????????dis,?????u,v??????????? { for(int j = i+1 ; j <= n ; j++) { dis[l]=sqrt((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3]))*1.00; u[l]=i; v[l]=j; l++; } } int m=0; //????????dis?????????????u,v????? int q=0; double p=0; for(int i = 1 ; i <= l-2 ; i++) { for(int j = 1 ; j < l-1 ; j++) { if(dis[j]<dis[j+1]) { p=dis[j]; dis[j]=dis[j+1]; dis[j+1]=p; m=u[j]; u[j]=u[j+1]; u[j+1]=m; q=v[j]; v[j]=v[j+1]; v[j+1]=q; } } } for(int i = 1 ; i <= l-1 ; i++) //?????? { cout<<"("<<a[u[i]][1]<<","<<a[u[i]][2]<<","<<a[u[i]][3]<<")-("<<a[v[i]][1]<<","<<a[v[i]][2]<<","<<a[v[i]][3]<<")"<<"="; printf("%.2f\n",dis[i]); } return 0; //??????????????????? }
64
31,892
int main() { int n,i=0,j=0,e=0,m=-1,q=-1; double a[100],b[100],c[100],t,g,f,r,v,s,o; double d[100],p[100]={0},w[100]={0},k[100]={0},z[100]={0},l[100]={0},u[100]={0}; cin>>n; for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; for(i=0;i<n*(n-1)/2;i++) d[i]=0; e=0; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) {d[e]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); p[e]=a[i]; w[e]=a[j]; u[e]=b[i]; l[e]=b[j]; k[e]=c[i]; z[e]=c[j]; e++; } for(i=0;i<(n*(n-1)/2)-1;i++) for(j=0;j<(n*(n-1)/2)-i-1;j++) { if(d[j]<d[j+1]) {t=d[j]; d[j]=d[j+1]; d[j+1]=t; g=p[j]; p[j]=p[j+1]; p[j+1]=g; f=w[j]; w[j]=w[j+1]; w[j+1]=f; r=u[j]; u[j]=u[j+1]; u[j+1]=r; v=l[j]; l[j]=l[j+1]; l[j+1]=v; s=k[j]; k[j]=k[j+1]; k[j+1]=s; o=z[j]; z[j]=z[j+1]; z[j+1]=o;} } for(i=0;i<(n*(n-1)/2);i++) {cout<<"("<<p[i]<<","<<u[i]<<","<<k[i]<<")"<<"-"<<"("<<w[i]<<","<<l[i]<<","<<z[i]<<")"<<"="; printf("%.2f\n",d[i]); } }
64
31,893
int main() { int n; int i,j,k=0; struct point { int x; int y; int z; }p[10]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z); } struct distant { struct point p1,p2; double r; }d[45],t; for(i=0;i<n;i++) { for(j=i+1;j<n;j++,k++) { d[k].p1=p[i]; d[k].p2=p[j]; d[k].r=sqrt(1.0*((d[k].p1.x-d[k].p2.x)*(d[k].p1.x-d[k].p2.x)+(d[k].p1.y-d[k].p2.y)*(d[k].p1.y-d[k].p2.y)+(d[k].p1.z-d[k].p2.z)*(d[k].p1.z-d[k].p2.z))); if(k>n*(n-1)/2) break; } if(k>n*(n-1)/2) break; } for(i=k-1;i>0;i--) { for(j=0;j<i;j++) { if(d[j].r<d[j+1].r) { t=d[j]; d[j]=d[j+1]; d[j+1]=t; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",d[i].p1.x,d[i].p1.y,d[i].p1.z,d[i].p2.x,d[i].p2.y,d[i].p2.z,d[i].r); } return 0; }
64
31,894
int main() {int n,i=0,j,p,q; int a[10][3]; double b[50],k,m; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) {scanf("%d",&a[i][j]);} } i=0; for(p=0;p<n-1;p++) { for(q=p+1;q<n;q++) {b[i]=1.0*sqrt((a[p][0]-a[q][0])*(a[p][0]-a[q][0])+(a[p][1]-a[q][1])*(a[p][1]-a[q][1])+(a[p][2]-a[q][2])*(a[p][2]-a[q][2])); i++;} } int index = i; for(j=index-1;j>0;j--) { for(i=0;i<j;i++) {if(b[i]>b[i+1]) {k=b[i]; b[i]=b[i+1]; b[i+1]=k; } } } b[n*(n-1)/2]=-1; for(i=n*(n-1)/2;i>=0;i--) {if(b[i]!=b[i+1]) { for(p=0;p<n;p++) { for(q=p+1;q<n;q++) {m=1.0*sqrt((a[p][0]-a[q][0])*(a[p][0]-a[q][0])+(a[p][1]-a[q][1])*(a[p][1]-a[q][1])+(a[p][2]-a[q][2])*(a[p][2]-a[q][2])); if(m==b[i]) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[p][0],a[p][1],a[p][2],a[q][0],a[q][1],a[q][2],m);} } } } } return 0; }
64
31,895
/* ????????.cpp * ???1200012826 ?? * ??? 2012?12?14? */ struct point { int x, y, z; } p[10]; struct distance { int a,b; double dis; } d[45], tr; int main() { int n, i, j, k=0; cin >> n; for(i=0; i<n; i++) { cin >> p[i].x >> p[i].y >> p[i].z; } for(i=0; i<n-1; i++) for(j=i+1; j<n; j++) { d[k].dis=sqrt((p[i].x-p[j].x)*(p[i].x-p[j].x)+(p[i].y-p[j].y)*(p[i].y-p[j].y)+(p[i].z-p[j].z)*(p[i].z-p[j].z)); d[k].a=i; d[k].b=j; k++; } for(i=0; i<k-1; i++) for(j=0; j<k-i-1; j++) { if(d[j].dis < d[j+1].dis) { tr=d[j]; d[j]=d[j+1]; d[j+1]=tr; } } for(i=0; i<k; i++) { cout << "(" << p[d[i].a].x << "," << p[d[i].a].y << "," << p[d[i].a].z << ")-(" << p[d[i].b].x << "," << p[d[i].b].y << "," << p[d[i].b].z << ")="; cout << fixed << setprecision(2) << d[i].dis << endl; } return 0; }
64
31,896
int main() { int n, i, j, k = 0; cin >> n; int num = n * (n - 1) / 2; int a[10][3]; for ( i = 0; i < n; i++) for ( j = 0; j < 3; j++) cin >> a[i][j]; double b[10][10]; double c[45]; for ( i = 0; i < n - 1; i++) for ( j = i + 1; j < n; j++) { double len1, len2, len3; len1 = pow(a[i][0] - a[j][0], 2.0); len2 = pow(a[i][1] - a[j][1], 2.0); len3 = pow(a[i][2] - a[j][2], 2.0); b[i][j] = sqrt(len1 + len2 + len3); c[k++] = b[i][j]; } double temp; for(i = 0; i < num - 1; i++) for (j = 0; j < num - 1 - i; j++) { if ((c[j] < c[j + 1]) ) { temp = c[j]; c[j] = c[j + 1]; c[j + 1] = temp; } } for (k = 0; k < num; k++) { if (k == 0) { for ( i = 0; i < n; i++) for ( j = i + 1; j < n; j++) if (fabs(b[i][j] - c[k]) < 1e-9) { cout << fixed; cout << "(" << a[i][0] << "," << a[i][1] << "," << a[i][2] << ")" << "-"; cout << "(" << a[j][0] << "," << a[j][1] << "," << a[j][2] << ")"; cout << "=" << setprecision(2) << b[i][j] << endl; } } else { while (fabs(c[k] - c[k - 1]) < 1e-9) k++; for ( i = 0; i < n; i++) for ( j = i + 1; j < n; j++) if (fabs(b[i][j] - c[k]) < 1e-9) { cout << fixed; cout << "(" << a[i][0] << "," << a[i][1] << "," << a[i][2] << ")" << "-"; cout << "(" << a[j][0] << "," << a[j][1] << "," << a[j][2] << ")"; cout << "=" << setprecision(2) << b[i][j] << endl; } } } return 0; }
64
31,897
int main(){ int a[10][4],m[45][4],n[45][4],i=0,j=0,k=0,p,q,w; double b[10][10],c[45]; scanf("%d",&w); for(i=0;i<w;i++){ scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]); } for(i=0;i<w;i++){ for(j=i+1;j<w;j++){ b[i][j]=(double)sqrt((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3])); } } for(k=0;k<w*(w-1)/2;k++){ c[k]=b[0][1]; p=0; q=1; for(i=0;i<w-1;i++){ for(j=i+1;j<w;j++){ if(c[k]<b[i][j]){ c[k]=b[i][j]; p=i; q=j; } } } b[p][q]=-1; m[k][1]=a[p][1];m[k][2]=a[p][2];m[k][3]=a[p][3]; n[k][1]=a[q][1];n[k][2]=a[q][2];n[k][3]=a[q][3]; } for(k=0;k<w*(w-1)/2;k++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",m[k][1],m[k][2],m[k][3],n[k][1],n[k][2],n[k][3],c[k]); } return 0; }
64
31,898
double distance(int b1[],int b2[]); int main() { int n,i,j,r=0,p,k=0; int a[30],b[10][3]; double d[100][3],temp; scanf("%d",&n); for(i=0;i<3*n;i++) scanf("%d",&a[i]); for(i=0;i<n;i++) { b[i][0]=a[3*i]; b[i][1]=a[3*i+1]; b[i][2]=a[3*i+2]; } for(i=0;i<n;i++) for(j=i+1;j<n;j++) { d[k][0]=distance(b[i],b[j]); d[k][1]=i; d[k][2]=j; k++; } for(i=1;i<k;i++) for(j=0;j<k-i;j++) if(d[j][0]<d[j+1][0]) { temp=d[j][0]; d[j][0]=d[j+1][0]; d[j+1][0]=temp; temp=d[j][1]; d[j][1]=d[j+1][1]; d[j+1][1]=temp; temp=d[j][2]; d[j][2]=d[j+1][2]; d[j+1][2]=temp; } for(p=0;p<k;p++) { i=d[p][1]; j=d[p][2]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i][0],b[i][1],b[i][2],b[j][0],b[j][1],b[j][2],d[p][0]); } return 0; } double distance(int b1[],int b2[]) { int X,Y,Z; double D; X=(b1[0]-b2[0])*(b1[0]-b2[0]); Y=(b1[1]-b2[1])*(b1[1]-b2[1]); Z=(b1[2]-b2[2])*(b1[2]-b2[2]); D=sqrt(X+Y+Z); return D; }
64
31,899
struct { int x; int y; int z; } dot[10]; struct { int f1; int f2; double dis; } d[55], t; int main() { int n, i, j, c = 0, x1, y1, z1; cin >> n; for (i = 0; i < n; i++) cin >> dot[i].x >> dot[i].y >> dot[i].z; for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { x1 = (dot[i].x - dot[j].x) * (dot[i].x - dot[j].x); y1 = (dot[i].y - dot[j].y) * (dot[i].y - dot[j].y); z1 = (dot[i].z - dot[j].z) * (dot[i].z - dot[j].z); d[c].f1 = i; d[c].f2 = j; d[c++].dis = sqrt(x1 + y1 + z1); } } for (i = 0; i < c; i++) for (j = c - 1; j > i; j--) { if (d[j].dis > d[j - 1].dis) { t = d[j - 1]; d[j - 1] = d[j]; d[j] = t; } } for (i = 0; i < c; i++) { cout << '(' << dot[d[i].f1].x << ',' << dot[d[i].f1].y << ',' << dot[d[i].f1].z << ")-(" << dot[d[i].f2].x << ',' << dot[d[i].f2].y << ',' << dot[d[i].f2].z << ")="; cout << fixed << setprecision(2) << d[i].dis << endl; } return 0; }
64