id
int32
0
32.5k
code
stringlengths
95
8.4k
label
stringclasses
65 values
31,700
struct { float a; int f,g; }s[50],temp; void main() { int n,i,j,x[10],y[10],z[10]; scanf("%d",&n); for(i=0;i<n;i++)scanf("%d%d%d",&x[i],&y[i],&z[i]); int t=0; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { s[t].a=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].f=i; s[t].g=j; t++; } for(i=0;i<t-1;i++) for(j=0;j<t-i-1;j++) if(s[j].a<s[j+1].a) { temp=s[j]; s[j]=s[j+1]; s[j+1]=temp; } for(i=0;i<t;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[s[i].f],y[s[i].f],z[s[i].f],x[s[i].g],y[s[i].g],z[s[i].g],s[i].a); }
64
31,701
int main() { int dian[10][3],n,j,i,k; int diandui[1000][6]; double d[1000]; scanf("%d",&n); for(j=0;j<n;j++) { for(i=0;i<3;i++) { scanf("%d",&dian[j][i]); } } int p=0; for(j=1;j<n;j++) { for(k=0;k<j;k++) { int x; x=(dian[j][0]-dian[k][0])*(dian[j][0]-dian[k][0])+(dian[j][1]-dian[k][1])*(dian[j][1]-dian[k][1])+(dian[j][2]-dian[k][2])*(dian[j][2]-dian[k][2]); d[p]=sqrt(x); diandui[p][0]=dian[k][0]; diandui[p][1]=dian[k][1]; diandui[p][2]=dian[k][2]; diandui[p][3]=dian[j][0]; diandui[p][4]=dian[j][1]; diandui[p][5]=dian[j][2]; p++; } } int a,b; for(k=0;k<p;k++) { for(i=0;i<p-k-1;i++) { double t; if(d[i]<d[i+1]) { t=d[i]; d[i]=d[i+1]; d[i+1]=t; for(a=0;a<6;a++) { b=diandui[i][a]; diandui[i][a]=diandui[i+1][a]; diandui[i+1][a]=b; } } } } for(i=0;i<p;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",diandui[i][0],diandui[i][1],diandui[i][2],diandui[i][3],diandui[i][4],diandui[i][5],d[i]); } return 0; }
64
31,702
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]; float d[45]; int s[45],e[45]; int t=0; 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,703
int main() { int n,a[10][3],i,j,d[45][2][2],k=0,c,x,y; double z; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]); } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { d[k][0][0]=i; d[k][0][1]=j; d[k][1][1]=(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<n*(n-1)/2-1;i++) { for(j=0;j<n*(n-1)/2-i-1;j++) { if(d[j][1][1]<d[j+1][1][1]) { c=d[j][0][0]; d[j][0][0]=d[j+1][0][0]; d[j+1][0][0]=c; c=d[j][0][1]; d[j][0][1]=d[j+1][0][1]; d[j+1][0][1]=c; c=d[j][1][1]; d[j][1][1]=d[j+1][1][1]; d[j+1][1][1]=c; } } } for(i=0;i<n*(n-1)/2;i++) { z=sqrt(d[i][1][1]*1.0); x=d[i][0][0]; y=d[i][0][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", a[x][0],a[x][1],a[x][2] ,a[y][0],a[y][1],a[y][2] ,z); } return 0; }
64
31,704
int main() { struct pointlong { int a1; int b1; int c1; int a2; int b2; int c2; double sl; }; struct pointlong point[10000]; int x[11]={0}; int y[11]={0}; int z[11]={0}; double a[11][11]={0}; double c[1000]={0}; int i,j,n,k,p,sum,w,f; float m; double temp; k=0; w=0; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d %d",&x[i],&y[i],&z[i]); } sum=n*(n-1)/2; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { m=(float)(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[i][j]=sqrt(m); } } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { c[k]=a[i][j]; k=k+1; } } for(i=1;i<sum;i++) { for(j=0;j<sum;j++) { if(c[j]<c[j+1]) { temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; } } } for(i=0;i<=sum;i++) { for(j=0;j<n;j++) { for(p=j+1;p<n;p++) { if(a[j][p]==c[i]) { point[w].a1=x[j]; point[w].b1=y[j]; point[w].c1=z[j]; point[w].a2=x[p]; point[w].b2=y[p]; point[w].c2=z[p]; point[w].sl=c[i]; w=w+1; } } } } for(i=0;i<w;i++) { f=0; for(j=0;j<i;j++) { if(point[i].a1==point[j].a1&&point[i].b1==point[j].b1&&point[i].c1==point[j].c1&&point[i].sl==point[j].sl&&point[i].a2==point[j].a2&&point[i].b2==point[j].b2&&point[i].c2==point[j].c2) { f=1; break; } } if(f==0) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",point[i].a1,point[i].b1,point[i].c1,point[i].a2,point[i].b2,point[i].c2,point[i].sl); } } return 0; }
64
31,705
//???? int main() { int n,a[10],b[10],c[10],s=0,x[100],y[100],ht; double d[100],max; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]>>b[i]>>c[i];//????? } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { d[s]=sqrt((a[i]*1.0-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); x[s]=i;y[s]=j; s++; }}//??????? for(int i=0;i<n*(n-1)/2;i++) { for(s=0;s<n*(n-1)/2-1;s++) { if(d[s]<d[s+1]) { max=d[s];d[s]=d[s+1];d[s+1]=max; ht=x[s];x[s]=x[s+1];x[s+1]=ht; ht=y[s];y[s]=y[s+1];y[s+1]=ht; }//???? } } for(s=0;s<=n*(n-1)/2 -1;s++) { cout<<'('<<a[x[s]]<<','<<b[x[s]]<<','<<c[x[s]]<<")-("<<a[y[s]]<<','<<b[y[s]]<<','<<c[y[s]]<<')'<<'='<<setprecision(2)<<fixed<<d[s]<<endl;//?? } return 0; }
64
31,706
int main() { int n,b,c,i,j,k,e,g; scanf("%d",&n); int sa[11],sb[11],sc[11]; for(i=0;i<n;i++) { scanf("%d%d%d",&sa[i],&sb[i],&sc[i]); } int s[51],y[51],z[51]; double l[51],f; i=0; for(j=0;j<n-1;j++) { for(k=j+1;k<n;k++) { s[i]=(sa[j]-sa[k])*(sa[j]-sa[k])+(sb[j]-sb[k])*(sb[j]-sb[k])+(sc[j]-sc[k])*(sc[j]-sc[k]); l[i]=sqrt(s[i]); y[i]=j; z[i]=k;//?????? i++; } } for(i=1;i<=(n*(n-1)/2);i++) { for(j=0;j<(n*(n-1)/2-i);j++) { if(l[j]<l[j+1]) { f=l[j]; l[j]=l[j+1]; l[j+1]=f;//???? e=y[j]; y[j]=y[j+1]; y[j+1]=e; g=z[j]; z[j]=z[j+1]; z[j+1]=g;//??????? } } } for(i=0;i<(n*(n-1)/2);i++) { b=y[i]; c=z[i]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sa[b],sb[b],sc[b],sa[c],sb[c],sc[c],l[i]); } return 0; }
64
31,707
int main(){ int n,m,t,i,j,x[15],y[15],z[15]; double s[150],k; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } t=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ s[t]=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]))); t++; } } for(i=1;i<=t-1;i++){ for(j=0;j<t-i;j++){ if(s[j]<s[j+1]){ k=s[j]; s[j]=s[j+1]; s[j+1]=k; } } } for(m=0;m<t;m++){ if(s[m]==s[m+1]){ continue; }else{ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(s[m]==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]))){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],s[m]); } } } } } return 0; }
64
31,708
int main() { int n,i,j,k; int x,y; int a[10][3]; double b[45][3],temp; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]); for(i=0,k=0;i<n;i++) for(j=i+1;j<n;j++){ b[k][0]=i; b[k][1]=j; b[k][2]=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=1;i<k;i++) for(j=0;j<k-i;j++){ if(b[j][2]<b[j+1][2]){ temp=b[j][0];b[j][0]=b[j+1][0];b[j+1][0]=temp; temp=b[j][1];b[j][1]=b[j+1][1];b[j+1][1]=temp; temp=b[j][2];b[j][2]=b[j+1][2];b[j+1][2]=temp; } if(b[j][2]==b[j+1][2]){ if(b[j][0]>b[j+1][0]){ temp=b[j][0];b[j][0]=b[j+1][0];b[j+1][0]=temp; temp=b[j][1];b[j][1]=b[j+1][1];b[j+1][1]=temp; temp=b[j][2];b[j][2]=b[j+1][2];b[j+1][2]=temp; } if(b[j][0]==b[j+1][0]) if(b[j][1]>b[j+1][1]){ temp=b[j][0];b[j][0]=b[j+1][0];b[j+1][0]=temp; temp=b[j][1];b[j][1]=b[j+1][1];b[j+1][1]=temp; temp=b[j][2];b[j][2]=b[j+1][2];b[j+1][2]=temp; } } } for(i=0;i<k;i++){ x=b[i][0];y=b[i][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[x][0],a[x][1],a[x][2],a[y][0],a[y][1],a[y][2],b[i][2]); } return 0; }
64
31,709
struct POINT{ int x, y, z; }; struct DISTANCE{ int pointx, pointy; double dis; }; int cmp(const void* e1, const void* e2){ struct DISTANCE* elem1 = (struct DISTANCE*)e1; struct DISTANCE* elem2 = (struct DISTANCE*)e2; if(elem1->dis == elem2->dis) return (elem1->pointx) - (elem2->pointx); if(elem1->dis > elem2->dis) return -1; return 1; } int main(){ int n; struct POINT data[11]; struct DISTANCE distance[10000]; scanf("%d", &n); int i; for(i=0; i<n; i++) scanf("%d %d %d", &(data[i].x), &(data[i].y), &(data[i].z)); int j; int cnt = 0; for(i=0; i<n; i++) for(j=i+1; j<n; j++){ distance[cnt].pointx = i; distance[cnt].pointy = j; distance[cnt].dis = sqrt((data[i].x-data[j].x)*(data[i].x-data[j].x)+(data[i].y-data[j].y)*(data[i].y-data[j].y)+(data[i].z-data[j].z)*(data[i].z-data[j].z)); cnt++; } qsort(distance, cnt, sizeof(struct DISTANCE), cmp); for(i=0; i<cnt; i++){ int x=distance[i].pointx; int y=distance[i].pointy; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", data[x].x, data[x].y, data[x].z, data[y].x, data[y].y, data[y].z, distance[i].dis); } return 0; }
64
31,710
struct twopoint{ float a1[3],a2[3],c; }b[45]; float a[10][3]; int select(float b[],int n){ int i,j,c; for(i=0;i<n;i++){ c=0; for(j=0;j<3;j++) if(b[j]==a[i][j]) c++; if(c==3) return(i); } } void selectsort(struct twopoint b[],int n,int m){ int i,j,k,i1,j1; float d[4]; struct twopoint temp; for(i=0;i<n;i++){ d[3]=0; for(j=0;j<3;j++){ d[j]=b[i].a1[j]-b[i].a2[j]; d[j]=d[j]*d[j]; d[3]+=d[j]; } b[i].c=sqrt(d[3]); } for(i=0;i<n-1;i++){ k=i; for(j=i+1;j<n;j++) if(b[j].c>b[k].c) k=j; else if(b[j].c==b[k].c){ i1=select(b[j].a1,m); j1=select(b[k].a1,m); if(i1<j1) k=j; if(i1==j1){ i1=select(b[j].a2,m); j1=select(b[k].a2,m); if(i1<j1) k=j; } } if(k!=i){ temp=b[k]; b[k]=b[i]; b[i]=temp; } } } main(){ int n1,n2,i,j,k,l=0,l1; scanf("%d",&n1); k=(n1-1)*n1/2; n2=n1; for(i=0;i<n1;i++) for(j=0;j<3;j++) scanf("%f",&a[i][j]); i=0; while(--n2>0){ l1=l; for(;l<l1+n2;l++) for(j=0;j<3;j++) b[l].a1[j]=a[i][j]; i++; } n2=n1;l=0;i=0; while(--n2>0){ l1=l;i++; for(;l<l1+n2;l++) for(j=0;j<3;j++) b[l].a2[j]=a[l-l1+i][j]; } selectsort(b,k,n1); for(i=0;i<k;i++) printf("(%g,%g,%g)-(%g,%g,%g)=%0.2f\n",b[i].a1[0],b[i].a1[1],b[i].a1[2],b[i].a2[0],b[i].a2[1],b[i].a2[2],b[i].c); }
64
31,711
/* * distance.cpp * * Created on: 2013-11-1 * Author: ???1300012996 */ int main(){ int n;cin>>n;int a[n][3];//??????????? for(int i=0;i<n;i++) for(int j=0;j<3;j++){ cin>>a[i][j]; } int m=n*(n-1)/2; double d[m],t;//?????????? int p=0,num[m][2],tt,ttt; for(int ii=0;ii<n;ii++) for(int jj=ii+1;jj<n;jj++){ d[p]=sqrt((a[ii][0]-a[jj][0])*(a[ii][0]-a[jj][0])+ (a[ii][1]-a[jj][1])*(a[ii][1]-a[jj][1])+ (a[ii][2]-a[jj][2])*(a[ii][2]-a[jj][2])); num[p][0]=ii;num[p][1]=jj;//?????????????????? p++; } for(int iii=1;iii<m;iii++) for(int jjj=0;jjj<m-iii;jjj++){ if(d[jjj]<d[jjj+1]){//?????????????????????????????? t=d[jjj];d[jjj]=d[jjj+1];d[jjj+1]=t; tt=num[jjj][0];num[jjj][0]=num[jjj+1][0];num[jjj+1][0]=tt; ttt=num[jjj][1];num[jjj][1]=num[jjj+1][1];num[jjj+1][1]=ttt; } } int iij,jji; for(int ij=0;ij<m;ij++){//????? iij=num[ij][0];jji=num[ij][1]; cout<<"("<<a[iij][0]<<"," <<a[iij][1]<<"," <<a[iij][2]<<")-(" <<a[jji][0]<<"," <<a[jji][1]<<"," <<a[jji][2]<<")=" <<fixed<<setprecision(2)<<d[ij]<<endl; } return 0; }
64
31,712
int main() { int n,i,k,j,sum=0,l=0; double di[100],e; struct i{ int x,y,z; }a[100],b[100],g,c[100]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { di[l]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); b[l]=a[i]; c[l]=a[j]; l++; } } for(k=1;k<=l;k++) { for(i=0;i<l-k;i++) { if(di[i]<di[i+1]) { e=di[i]; di[i]=di[i+1]; di[i+1]=e; g=b[i]; b[i]=b[i+1]; b[i+1]=g; g=c[i]; c[i]=c[i+1]; c[i+1]=g; } } } for(i=0;i<l;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i].x,b[i].y,b[i].z,c[i].x,c[i].y,c[i].z,di[i]); return 0; }
64
31,713
int main() { int n,j,q; scanf("%d",&n); struct zb { int x,y,z; } zb[1000]; for(q=0;q<n;q++){ scanf("%d%d%d",&(zb[q].x),&(zb[q].y),&(zb[q].z)); } int i=0; struct jl { int x1,x2,y1,y2,z1,z2; double s; } jl[1000]; for(q=0;q<n-1;q++){ for(j=q+1;j<n;j++){ jl[i].x1=zb[q].x; jl[i].x2=zb[j].x; jl[i].y1=zb[q].y; jl[i].y2=zb[j].y; jl[i].z1=zb[q].z; jl[i].z2=zb[j].z; int a,b,c; double f; a=jl[i].x1-jl[i].x2; b=jl[i].y1-jl[i].y2; c=jl[i].z1-jl[i].z2; f=a*a+b*b+c*c; jl[i].s=sqrt(f); i++; } } int m; m=i; for(q=1;q<=m;q++){ for(j=0;j<m-q;j++){ if((jl[j+1].s)>(jl[j].s)){ jl[1000]=jl[j+1]; jl[j+1]=jl[j]; jl[j]=jl[1000]; } } } for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",jl[i].x1,jl[i].y1,jl[i].z1,jl[i].x2,jl[i].y2,jl[i].z2,jl[i].s); } return 0; }
64
31,714
int main() { int k,i,n,t,o,p,q=0; int x[100],y[100],z[100],one[100],two[100]; double e,sz[100]; 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(p=i+1;p<n;p++) { sz[q]=sqrt((x[i]-x[p])*(x[i]-x[p])+(y[i]-y[p])*(y[i]-y[p])+(z[i]-z[p])*(z[i]-z[p])); one[q]=i;two[q]=p; q++; } } for(k=1;k<q+1;k++) { for(i=0;i<q-k;i++) { if(sz[i]<sz[i+1]) { e=sz[i+1];t=one[i+1];o=two[i+1]; sz[i+1]=sz[i];one[i+1]=one[i];two[i+1]=two[i]; sz[i]=e;one[i]=t;two[i]=o; } } } for(i=0;i<q;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[(one[i])],y[(one[i])],z[(one[i])],x[(two[i])],y[(two[i])],z[(two[i])],sz[i]); } return 0; }
64
31,715
int main() { int n,i,j,k; int a[11][3]; float d[10][10]={0},h=0.0; float max=0.0; cin>>n; for (i=0;i<n;i++) cin>>a[i][0]>>a[i][1]>>a[i][2]; for (i=0;i<n;i++) for (j=i+1;j<n;j++) { h=(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]); d[i][j]=sqrt(h); } for (k=0;k<n*(n-1)/2;k++) { for (i=0;i<n;i++) for (j=i+1;j<n;j++) if (d[i][j]>max) max=d[i][j]; for (i=0;i<n;i++) for (j=i+1;j<n;j++) if (d[i][j]==max) { cout<<"("<<a[i][0]<<","<<a[i][1]<<","<<a[i][2]<<")-(" <<a[j][0]<<","<<a[j][1]<<","<<a[j][2]<<")=" <<fixed<<setprecision(2)<<d[i][j]<<endl; d[i][j]=-1; } max=0.0; } return 0; }
64
31,716
int main(){ int n,l=0,x[101],y[101],z[101],a[101],b[101],i; double m[101]; scanf("%d\n",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(int k=0;k<n-1;k++){ for(i=k+1;i<n;i++){ m[l]=sqrt(1.0*(x[k]-x[i])*(x[k]-x[i])+1.0*(y[k]-y[i])*(y[k]-y[i])+1.0*(z[k]-z[i])*(z[k]-z[i])); a[l]=k; b[l]=i; l++; } } for(int k=1;k<=l;k++){ double e; for(i=0;i<l-k;i++){ if(m[i]<m[i+1]){ e=m[i+1]; m[i+1]=m[i]; m[i]=e; e=a[i+1]; a[i+1]=a[i]; a[i]=e; e=b[i+1]; b[i+1]=b[i]; b[i]=e; } } } for(i=0;i<l;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]],m[i]);} return 0; }
64
31,717
float juli(float x1,float y1,float z1,float x2,float y2,float z2) { return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2)); } int main() { int n,u=0; int i,j,t; float x[10],y[10],z[10],d[50],m; int a[50],b[50]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%f %f %f",&x[i],&y[i],&z[i]); } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { d[u]=juli(x[i],y[i],z[i],x[j],y[j],z[j]); a[u]=i; b[u]=j; u++; } } for(i=0;i<u;i++) { for(j=u-1;j>i;j--) { if(d[j]>d[j-1]) { m=d[j]; d[j]=d[j-1]; d[j-1]=m; t=a[j]; a[j]=a[j-1]; a[j-1]=t; t=b[j]; b[j]=b[j-1]; b[j-1]=t; } } } for(i=0;i<u;i++) { printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],d[i]); } return 0; }
64
31,718
int main() { int i,n,j,k=0; struct zuobiao { int x; int y; int z; } a[10]; struct juli { double d; struct zuobiao a1; struct zuobiao b1; } b[100],tem; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { b[k].d=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); b[k].a1=a[i]; b[k].b1=a[j]; k++; } } n=n*(n-1)/2; for(i=1;i<n;i++) //???? { for(j=i;j>0;j--) { if(b[j].d>b[j-1].d) { tem=b[j]; b[j]=b[j-1]; b[j-1]=tem; } } } for(i=0;i<n;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i].a1.x,b[i].a1.y,b[i].a1.z,b[i].b1.x,b[i].b1.y,b[i].b1.z,b[i].d); } return 0; }
64
31,719
int main(){ int x[10],y[10],z[10],weizhi[200],t,n,i,j,k,a,b; double juli[200],m,pingfanghe[200]; scanf("%d",&n); k=0; for(i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ pingfanghe[k]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); juli[k]=sqrt(pingfanghe[k]); weizhi[k]=i*10+j; k++; } } k--; for(i=k;i>0;i--){ for(j=0;j<i;j++){ if(juli[j]<juli[j+1]){ m=juli[j]; juli[j]=juli[j+1]; juli[j+1]=m; t=weizhi[j]; weizhi[j]=weizhi[j+1]; weizhi[j+1]=t; } } } for(i=0;i<=k;i++){ a=weizhi[i]/10; b=weizhi[i]%10; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a],y[a],z[a],x[b],y[b],z[b],juli[i]); } return 0; }
64
31,720
int main() { float point[10][3],lon[100],tem1; int n,i,j,sum=0,x[100],y[100],tem; cin>>n; for(i=0;i<n;i++) cin>>point[i][0]>>point[i][1]>>point[i][2]; for(i=0;i<n;i++) for(j=i+1;j<n;j++) { lon[sum]=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])); x[sum]=i; y[sum++]=j; } for(i=0;i<sum-1;i++) for(j=0;j<sum-i-1;j++) { if(lon[j]<lon[j+1]) { tem1=lon[j]; lon[j]=lon[j+1]; lon[j+1]=tem1; tem=x[j]; x[j]=x[j+1]; x[j+1]=tem; tem=y[j]; y[j]=y[j+1]; y[j+1]=tem; } } for(i=0;i<sum;i++) { cout<<'('; cout<<point[x[i]][0]<<','<<point[x[i]][1]<<','<<point[x[i]][2]<<')'; cout<<'-'; cout<<'('; cout<<point[y[i]][0]<<','<<point[y[i]][1]<<','<<point[y[i]][2]<<')'; cout<<'='; printf("%.2f",lon[i]); cout<<endl; } }
64
31,721
int main() { int X[120], Y[120], Z[120], I[1020], J[1020]; double R2[1020], mid; int n; int i, x, y, z, a, b, pai, mi; cin >> n; for (i = 1; i <= n; i++) { cin >> x >> y >> z; X[i] = x; Y[i] = y; Z[i] = z; } int r = 1; for (a = 1; a <= n; a++) { for (b = 2; b <= n; b++) { if (b <= a) { continue; } I[r] = a; J[r] = b; R2[r] = (X[a] - X[b]) * (X[a] - X[b]) + (Y[a] - Y[b]) * (Y[a] - Y[b]) + (Z[a] - Z[b]) * (Z[a] - Z[b]); r++; } } pai = n * (n - 1) / 2 + 1; while (pai--) { for (i = 1; i < r - 1; i++) { if (R2[i] < R2[i + 1]) { mid = R2[i]; R2[i] = R2[i + 1]; R2[i + 1] = mid; mi = J[i]; J[i] = J[i + 1]; J[i + 1] = mi; mi = I[i]; I[i] = I[i + 1]; I[i + 1] = mi; } } } for (i = 1; i <= n * (n - 1) / 2; i++) { R2[i] = sqrt(R2[i]); cout << "(" << X[I[i]] << "," << Y[I[i]] << "," << Z[I[i]] << ")-(" << X[J[i]] << "," << Y[J[i]] << "," << Z[J[i]] << ")=" << fixed << setprecision(2) << R2[i] << endl; } return 0; }
64
31,722
void main() { struct point { int x; int y; int z; }P[10]; struct triple { struct point A; struct point B; double d; }pair[50],tmp; int n,i,j,k,c[31]; scanf("%d",&n); for(i=1;i<=3*n;i++) scanf("%d",&c[i]); for(i=0;i<n;i++) { (P[i]).x=c[3*i+1]; (P[i]).y=c[3*i+2]; (P[i]).z=c[3*i+3]; } for(i=0;i<n;i++) for(j=i+1;j<n;j++) { k=i*n+j-i*(i+3)/2; (pair[k]).A=P[i]; (pair[k]).B=P[j]; int X=P[i].x-P[j].x; int Y=P[i].y-P[j].y; int Z=P[i].z-P[j].z; (pair[k]).d=sqrt(X*X+Y*Y+Z*Z); } for(i=n*(n-1)/2;i>1;i--) for(k=1;k<i;k++) { if ((pair[k]).d<(pair[k+1]).d) { tmp=pair[k+1]; pair[k+1]=pair[k]; pair[k]=tmp; } } for(k=1;k<=n*(n-1)/2;k++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",(pair[k]).A.x,(pair[k]).A.y,(pair[k]).A.z,(pair[k]).B.x,(pair[k]).B.y,(pair[k]).B.z,(pair[k]).d); }
64
31,723
struct point { int x[2]; int y[2]; int z[2]; float s; }p[100],q; float distant (int x1,int y1, int z1,int x2,int y2,int z2) { float m,e; e=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2); m=sqrt(e); return (m); } int main () { int n,x[11]={0},y[11]={0},z[11]={0},i,j=0,s[100]={0},k,t=1; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n*(n-1)/2;i++) { p[i].x[0]=x[j]; p[i].y[0]=y[j]; p[i].z[0]=z[j]; p[i].x[1]=x[j+t]; p[i].y[1]=y[j+t]; p[i].z[1]=z[j+t]; t++; if(j+t>n-1) { j++; t=1; } } for(i=0;i<n*(n-1)/2;i++) { p[i].s=distant(p[i].x[0],p[i].y[0],p[i].z[0],p[i].x[1],p[i].y[1],p[i].z[1]); } for(k=1;k<=n*(n-1)/2;k++) { for(i=0;i<n*(n-1)/2;i++) { if(p[i].s<p[i+1].s) { q=p[i]; p[i]=p[i+1]; p[i+1]=q; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",p[0].x[0],p[0].y[0],p[0].z[0],p[0].x[1],p[0].y[1],p[0].z[1],p[0].s); for(i=1;i<n*(n-1)/2;i++) printf("\n(%d,%d,%d)-(%d,%d,%d)=%.2f",p[i].x[0],p[i].y[0],p[i].z[0],p[i].x[1],p[i].y[1],p[i].z[1],p[i].s); return 0; }
64
31,724
int main (){ int n,i,j,k,h,l; scanf("%d",&n); k=0; int a[11]; int b[11]; int c[11]; int f[100]; int e[100]; double d[10000]; for(i=0;i<n;i++){ scanf("%d%d%d",&(a[i]),&(b[i]),&(c[i])); } k=1; d[0]=0; for(j=0;j<n;j++){ for(i=j+1;i<n;i++){ d[k]=sqrt((a[j]-a[i])*(a[j]-a[i])+(b[j]-b[i])*(b[j]-b[i])+(c[j]-c[i])*(c[j]-c[i])); e[k]=i; f[k]=j; //??d[k]???j,i k++; }l=k; }for(h=0;h<n*n;h++){ for(k=0;k<=l;k++){ if(d[k]!=0){ for(i=0;i<=l;i++){ if(d[k]<d[i]){ break; }if(i==(l-1)){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[f[k]],b[f[k]],c[f[k]],a[e[k]],b[e[k]],c[e[k]],d[k]); d[k]=0; k=0; i=0; break; } } } } } return 0; }
64
31,725
int main() { int n, i, j, k, l, m, a, b; int x[12] = {0}; int y[12] = {0}; int z[12] = {0}; double d[12][12] = {0}; double max; int pm[12][12] = {0}; cin >> n; for (i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> z[i]; } for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { d[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])); } } max = -1.0; k = n * (n - 1) / 2; for (l = 1; l <= k; l++) { for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { if (d[i][j] - max > 1e-10) { max = d[i][j]; a = i; b = j; } } } cout << "(" << x[a] << "," << y[a] << "," << z[a] << ")" << "-" << "(" << x[b] << "," << y[b] << "," << z[b] << ")" << "=" << fixed << setprecision(2) << d[a][b] << endl; d[a][b] = 0; max = - 1; } return 0; }
64
31,726
int main() { int n,i,h,k,m; scanf("%d",&n); double dj[30]; struct dian { double x,y,z; } d[10]; struct jl { double x1,y1,z1,x2,y2,z2; double c; } cd[46]; for(i=0;i<3*n;i++){ scanf("%lf",&(dj[i]));} for(i=0;i<n;i++){ d[i].x=dj[3*i]; d[i].y=dj[3*i+1]; d[i].z=dj[3*i+2];} k=0; for(i=0;i<n-1;i++){ for(h=1;h<n-i;h++){ cd[k].x1=d[i].x; cd[k].y1=d[i].y; cd[k].z1=d[i].z; cd[k].x2=d[i+h].x; cd[k].y2=d[i+h].y; cd[k].z2=d[i+h].z; cd[k].c=sqrt(((cd[k].x1-cd[k].x2)*(cd[k].x1-cd[k].x2)+(cd[k].y1-cd[k].y2)*(cd[k].y1-cd[k].y2)+(cd[k].z1-cd[k].z2)*(cd[k].z1-cd[k].z2))); k++;}} m=k; for(k=1;k<m;k++){ for(i=0;i<m-k;i++){ if((cd[i].c)<(cd[i+1].c)){ cd[45]=cd[i+1]; cd[i+1]=cd[i]; cd[i]=cd[45];}}} for(i=0;i<m;i++){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",cd[i].x1,cd[i].y1,cd[i].z1,cd[i].x2,cd[i].y2,cd[i].z2,cd[i].c);} return 0;}
64
31,727
int main(){ int n; scanf("%d",&n); int *x=(int*)malloc(sizeof(int)*n); int *y=(int*)malloc(sizeof(int)*n); int *z=(int*)malloc(sizeof(int)*n); int i,j; for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } double *d=(double*)malloc(sizeof(double)*((n-1)*n/2)); int *number1=(int*)malloc(sizeof(int)*((n-1)*n/2)); int *number2=(int*)malloc(sizeof(int)*((n-1)*n/2)); int pos=0; //number1?number2??????? (n-1)*n/2 for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ //d[i]=sqrt((x[i]-x[j])^2+(y[i]-y[j])^2+(z[i]-z[j])^2); //~???????? d[pos]=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)+pow(z[i]-z[j],2)); number1[pos]=i; number2[pos]=j; pos++; } } int k,f,g; double e; for(k=1;k<=(n-1)*n/2;k++){ for(i=0;i<(n-1)*n/2-k;i++){ if(d[i]<d[i+1]){ e=d[i]; d[i]=d[i+1]; d[i+1]=e; f=number1[i]; number1[i]=number1[i+1]; number1[i+1]=f; g=number2[i]; number2[i]=number2[i+1]; number2[i+1]=g; } } } for(k=0;k<(n-1)*n/2;k++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[number1[k]],y[number1[k]],z[number1[k]],x[number2[k]],y[number2[k]],z[number2[k]],d[k]); } free(x); free(y); free(z); free(number1); free(number2); return 0; }
64
31,728
int r(int k,int n) { int i; for(i=n-1;k>i;i--) k-=i; return(n-i-1); } int p(int k,int n) { int i; for(i=n-1;k>i;i--) k-=i; return(n-i+k-1); } void main() { int n,i,j,k=0,q[50],t,g,h; float y[50]; struct point{int a; int b; int c; }x[12]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&x[i].a,&x[i].b,&x[i].c); for(i=0;i<n;i++) for(j=i+1;j<n;j++,k++) y[k]=sqrt((x[i].a-x[j].a)*(x[i].a-x[j].a)+(x[i].b-x[j].b)*(x[i].b-x[j].b)+(x[i].c-x[j].c)*(x[i].c-x[j].c)); for(i=0;i<=n*(n-1)/2;i++) q[i]=i; for(i=0;i<n*(n-1)/2-1;i++) for(j=0;j<n*(n-1)/2-1-i;j++) if(y[q[j]]<y[q[j+1]]) {t=q[j]; q[j]=q[j+1]; q[j+1]=t; } for(i=0;i<n*(n-1)/2;i++) { g=r(q[i]+1,n); h=p(q[i]+1,n); printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[g].a,x[g].b,x[g].c,x[h].a,x[h].b,x[h].c,y[q[i]]); } }
64
31,729
int main() { int a,c,k,i,m,j,n,x[101],y[101],z[101],xs[101],ys[101],zs[101],xz[101],yz[101],zz[101]; double b,l[10][10],ls[100]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ l[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])); } } a=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ xs[a]=x[i]; ys[a]=y[i]; zs[a]=z[i]; xz[a]=x[j]; yz[a]=y[j]; zz[a]=z[j]; ls[a]=l[i][j]; a++; m=a; } } k=0; while(k<=m){ for(i=0;i<m-1;i++){ if(ls[i]>=ls[i+1]){ ls[i]=ls[i]; ls[i+1]=ls[i+1]; }else{ b=ls[i]; ls[i]=ls[i+1]; ls[i+1]=b; c=xs[i]; xs[i]=xs[i+1]; xs[i+1]=c; c=ys[i]; ys[i]=ys[i+1]; ys[i+1]=c; c=zs[i]; zs[i]=zs[i+1]; zs[i+1]=c; c=xz[i]; xz[i]=xz[i+1]; xz[i+1]=c; c=yz[i]; yz[i]=yz[i+1]; yz[i+1]=c; c=zz[i]; zz[i]=zz[i+1]; zz[i+1]=c; } } k++; } for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",xs[i],ys[i],zs[i],xz[i],yz[i],zz[i],ls[i]); } return 0; }
64
31,730
int main(){ int n,i,j,m,k=0,x[10],y[10],z[10],a[50],b[50]; double d[50],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;i++){ for(j=i+1;j<n;j++){ a[k]=i; b[k]=j; d[k]=sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j])+1.0*(z[i]-z[j])*(z[i]-z[j])); k++; } } for(i=k;i>0;i--){ for(j=k-1;j>0;j--){ if(d[j]>d[j-1]){ e=d[j]; d[j]=d[j-1]; d[j-1]=e; 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",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],d[i]); } return 0; }
64
31,731
int main() { int n,a[10],b[10],c[10],i,j,x,m=0; double sun[10][10],s[50],k; 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+1;j<n;j++){ sun[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])); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ s[m]=sun[i][j]; m++; } } for(i=0;i<m;i++){ for(j=i+1;j<m;j++){ if(s[j]>s[i]){ k=s[i]; s[i]=s[j]; s[j]=k; } } } for(i=0;i<m;i++){ if(s[i]==s[i+1]){ for(j=i+1;j<m;j++){ s[j]=s[j+1]; i=i-1; m=m-1; } } } for(x=0;x<m;x++){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(s[x]==sun[i][j]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],a[j],b[j],c[j],sun[i][j]); } } } } return 0; }
64
31,732
int main() { int n,i,j=0,k=0,len,sum=0; double di[100],l; struct i{ int x,y,z; }a[100],b[100],c[100],e; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { di[k]=sqrt(1.0*(a[i].x-a[j].x)*(a[i].x-a[j].x)+1.0*(a[i].y-a[j].y)*(a[i].y-a[j].y)+1.0*(a[i].z-a[j].z)*(a[i].z-a[j].z)); b[k]=a[i]; c[k]=a[j]; k++; } } for(i=1;i<=k;i++) { for(j=0;j<k-i;j++) { if(di[j]<di[j+1]) { l=di[j]; di[j]=di[j+1]; di[j+1]=l; e=b[j]; b[j]=b[j+1]; b[j+1]=e; e=c[j]; c[j]=c[j+1]; c[j+1]=e; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i].x,b[i].y,b[i].z,c[i].x,c[i].y,c[i].z,di[i]); } return 0; }
64
31,733
int row(int a,int n) { int i=n-1; while(a>i) { a-=i; i-=1; } return(n-1-i); } int col(int a,int n) { int i=n-1; while(a>i) { a-=i; i-=1; }return(n-1-i+a); } int main() { struct spot {int x; int y; int z; }a[11]; int n,i,j,l=0,c[55],temp,h,g; double b[55]; scanf("%d",&n); for(i=0;i<55;i++) c[i]=i; for(i=0;i<n;i++) { scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].z); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { b[l]=(double)sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); l++; } } for(i=0;i<l-1;i++) { for(j=0;j<l-i-1;j++) { if(b[c[j]]<b[c[j+1]]) { temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; } } } for(i=0;i<n*(n-1)/2;i++) {h=col(c[i]+1,n); g=row(c[i]+1,n); printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[g].x,a[g].y,a[g].z,a[h].x,a[h].y,a[h].z,b[c[i]]); } return 0; }
64
31,734
int main() { int x[10],y[10],z[10],x1[45],y1[45],z1[45],x2[45],y2[45],z2[45],n,m,i,j,k,l,h; double s[45],e; scanf("%d",&n); m=n*(n-1)/2; for(i=0;i<n;i++) scanf("%d %d %d",&x[i],&y[i],&z[i]); l=0; for(j=0;j<n-1;j++){ for(k=j+1;k<n;k++){ x1[l]=x[j];y1[l]=y[j];z1[l]=z[j]; x2[l]=x[k];y2[l]=y[k];z2[l]=z[k]; s[l]=sqrt((x[j]-x[k])*(x[j]-x[k])+(y[j]-y[k])*(y[j]-y[k])+(z[j]-z[k])*(z[j]-z[k])); l++; } } for(j=1;j<=m;j++){ for(k=0;k<m-j;k++){ if(s[k]<s[k+1]){ e=s[k];s[k]=s[k+1];s[k+1]=e; h=x1[k];x1[k]=x1[k+1];x1[k+1]=h; h=y1[k];y1[k]=y1[k+1];y1[k+1]=h; h=z1[k];z1[k]=z1[k+1];z1[k+1]=h; h=x2[k];x2[k]=x2[k+1];x2[k+1]=h; h=y2[k];y2[k]=y2[k+1];y2[k+1]=h; h=z2[k];z2[k]=z2[k+1];z2[k+1]=h; } } } for(i=0;i<m;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x1[i],y1[i],z1[i],x2[i],y2[i],z2[i],s[i]); return 0; }
64
31,735
int main() { int n,i,j,k; float x[20],y[20],z[20],d[20][20]={0}; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%f%f%f",&x[i],&y[i],&z[i]); } for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { d[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])); } } double count=0; hell:; double max=0; int a,b; for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { if(d[i][j]>max) { max=d[i][j]; a=i;b=j; } } } printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2lf\n",x[a],y[a],z[a],x[b],y[b],z[b],max); d[a][b]=-1; count++; if(count<(n*(n-1))/2) goto hell; }
64
31,736
int main(){ int n,i,x[100],y[100],z[100],k,t; double s[1000],e; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } t=0; for(k=0;k<n;k++){ for(i=k+1;i<n;i++){ s[t]=sqrt(1.0*((x[k]-x[i])*(x[k]-x[i])+(y[k]-y[i])*(y[k]-y[i])+(z[k]-z[i])*(z[k]-z[i]))); t++; } } for(i=1;i<=n*(n-1)/2;i++){ for(t=0;t<n*(n-1)/2-i;t++){ if(s[t]<s[t+1]){ e=s[t]; s[t]=s[t+1]; s[t+1]=e; } } } for(t=0;t<n*(n-1)/2;t++){ if(s[t]==s[t+1]){ continue; }else{ for(k=0;k<n;k++){ for(i=k+1;i<n;i++){ if(s[t]==sqrt(1.0*((x[k]-x[i])*(x[k]-x[i])+(y[k]-y[i])*(y[k]-y[i])+(z[k]-z[i])*(z[k]-z[i])))) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[k],y[k],z[k],x[i],y[i],z[i],s[t]); } } } } return 0; }
64
31,737
int main(){ int m,n,i,k,s=0,p,q; double c[45]; double e; double d[10][3]; scanf("%d",&n); for(m=0;m<n;m++){ for(i=0;i<3;i++){ scanf("%lf",&(d[m][i])); } } for(m=0;m<n;m++){ for(k=m+1;k<n;k++){ c[s]=sqrt((d[m][0]-d[k][0])*(d[m][0]-d[k][0])+(d[m][1]-d[k][1])*(d[m][1]-d[k][1])+(d[m][2]-d[k][2])*(d[m][2]-d[k][2])); s=s+1; }} for(p=1;p<=s;p++){ for(i=0;i<s-p;i++){ if(c[i]>c[i+1]){ e=c[i+1]; c[i+1]=c[i]; c[i]=e; } }} for(q=s-1;q>=0;q--){ for(m=0;m<n;m++){ for(k=m+1;k<n;k++){ if(sqrt((d[m][0]-d[k][0])*(d[m][0]-d[k][0])+(d[m][1]-d[k][1])*(d[m][1]-d[k][1])+(d[m][2]-d[k][2])*(d[m][2]-d[k][2]))==c[q]){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n", d[m][0], d[m][1], d[m][2], d[k][0],d[k][1], d[k][2],c[q]); } } } for(p=q;p>0;p=p-1){ if(c[p]==c[p-1]){ q=q-1; } else break; } } return 0; }
64
31,738
int main() { double f(int a[],int b[]); int n,a[10][3],count=0,i,j,k,d[45][2],num=0; int g(int i,int j,int k,int d[][2],double b[],int n); double t,b[45]; 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-1;i++) for(j=i+1;j<n;j++) {b[count]=f(a[i],a[j]); count++;} for(i=0;i<n*(n-1)/2-1;i++) for(j=0;j<n*(n-1)/2-1-i;j++) if(b[j]<b[j+1]) {t=b[j];b[j]=b[j+1];b[j+1]=t;} for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) if(f(a[i],a[j])==b[0]) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],a[j][0],a[j][1],a[j][2],b[0]);d[0][0]=i;d[0][1]=j;num++;break;} if(num==1) {num=0;break;} } for(k=1;k<n*(n-1)/2;k++) for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) if(f(a[i],a[j])==b[k]) { if(b[k]!=b[k-1]) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],a[j][0],a[j][1],a[j][2],b[k]);d[k][0]=i;d[k][1]=j; num++; break;} else if(g(i,j,k,d,b,n)) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],a[j][0],a[j][1],a[j][2],b[k]);d[k][0]=i;d[k][1]=j; num++; break;} } if(num==1) {num=0; break;} } return 0; } double f(int a[],int b[]) {double d; d=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2])); return d; } int g(int i,int j,int k,int d[][2],double b[],int n) {int x,num1=0; for(x=0;x<=k;x++) if(b[x]==b[k]) num1++; for(x=1;x<num1;x++) if(d[k-x][0]==i&&d[k-x][1]==j) {return 0;break;} if(x>=num1) return 1; }
64
31,739
typedef struct { int x; int y; int z; } point3D; //????????? typedef struct { int firstPointIndex; //??????? int lastPointIndex; //??????? float distance;//????? } result; //???? ?????? float getDistance(point3D p1, point3D p2) { int temp; temp = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y) + (p1.z - p2.z) * (p1.z - p2.z); return sqrtf((float)temp); } int main() { point3D points[MAXPOINTS]; //????? ??????? result results[MAXRESULTS];//?????????????? int i, j, k, pointNum, resultNum; result temp; //????? scanf("%d", &pointNum); resultNum = pointNum * (pointNum - 1) / 2; //????? for (i = 0; i < pointNum; i++) { scanf("%d", &points[i].x); scanf("%d", &points[i].y); scanf("%d", &points[i].z); } //?????? k = 0; for (i = 0; i < pointNum; i++) { for (j = i + 1; j < pointNum; j++) { results[k].firstPointIndex = i; results[k].lastPointIndex = j; results[k].distance = getDistance(points[i], points[j]); k++; } } //?????????? ?????? for (i = 0; i < resultNum - 1; i++) for (j = 0; j < resultNum - i - 1; j++) { if (results[j].distance < results[j + 1].distance ) { temp = results[j]; results[j] = results[j + 1]; results[j + 1] = temp; } } //???? for (i = 0; i < resultNum; i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", points[results[i].firstPointIndex].x, points[results[i].firstPointIndex].y, points[results[i].firstPointIndex].z, points[results[i].lastPointIndex].x, points[results[i].lastPointIndex].y, points[results[i].lastPointIndex].z, results[i].distance); } return 0; }
64
31,740
//============================================================================ // Name : 3.cpp // Author : // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ int main() { int n; cin>>n; int x[n],y[n],z[n]; //x[n],y[n],z[n]????????? int f=n*(n-1)/2; //f?????? for(int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i]; int a1[f],b1[f],c1[f],a2[f],b2[f],c2[f]; float e[f]; int d=0; int num[f]; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { a1[d]=x[i]; //???????? b1[d]=y[i]; c1[d]=z[i]; a2[d]=x[j]; b2[d]=y[j]; c2[d]=z[j]; e[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])); num[d]=d; d++; //e[f]??????? } int m=0; //m,n1???????????? float n1=0; for(int i=0;i<f;i++) for(int j=i+1;j<f;j++) { if(e[i]<e[j]) { n1=e[i];e[i]=e[j];e[j]=n1; m=a1[i];a1[i]=a1[j];a1[j]=m; m=b1[i];b1[i]=b1[j];b1[j]=m; m=c1[i];c1[i]=c1[j];c1[j]=m; m=a2[i];a2[i]=a2[j];a2[j]=m; m=b2[i];b2[i]=b2[j];b2[j]=m; m=c2[i];c2[i]=c2[j];c2[j]=m; m=num[i];num[i]=num[j];num[j]=m; } if((e[i]==e[j])&&(num[i]>num[j])) //???????????? { n1=e[i];e[i]=e[j];e[j]=n1; m=a1[i];a1[i]=a1[j];a1[j]=m; m=b1[i];b1[i]=b1[j];b1[j]=m; m=c1[i];c1[i]=c1[j];c1[j]=m; m=a2[i];a2[i]=a2[j];a2[j]=m; m=b2[i];b2[i]=b2[j];b2[j]=m; m=c2[i];c2[i]=c2[j];c2[j]=m; m=num[i];num[i]=num[j];num[j]=m; } } for(int i=0;i<f;i++) cout<<"("<<a1[i]<<","<<b1[i]<<","<<c1[i]<<")-("<<a2[i]<<","<<b2[i]<<","<<c2[i]<<")="<<fixed<<setprecision(2)<<e[i]<<endl; return 0; }
64
31,741
/* * Distance sorting.cpp * * Created on: 2013-11-6 * Author: ??? */ int main() { int a[10],b[10],c[10]; float d[100],p,x[100][3],y[100][3]; int i,j,n,k,m=0,s,t; cin>>n; for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { x[m][0]=a[i]; x[m][1]=b[i]; x[m][2]=c[i]; y[m][0]=a[j]; y[m][1]=b[j]; y[m][2]=c[j]; d[m]=sqrt((x[m][0]-y[m][0])*(x[m][0]-y[m][0])+(x[m][1]-y[m][1])*(x[m][1]-y[m][1])+(x[m][2]-y[m][2])*(x[m][2]-y[m][2])); m++; } } for(j=0;j<m-1;j++) { for(i=0;i<m-1-j;i++) { if(d[i]<d[i+1]) { p=d[i]; d[i]=d[i+1]; d[i+1]=p; for(k=0;k<3;k++) { s=x[i][k]; x[i][k]=x[i+1][k]; x[i+1][k]=s; t=y[i][k]; y[i][k]=y[i+1][k]; y[i+1][k]=t; } } } } for(i=0;i<m;i++) cout<< fixed<<setprecision(0)<<"("<<x[i][0]<<","<<x[i][1]<<","<<x[i][2]<<")-("<<y[i][0]<<","<<y[i][1]<<","<<y[i][2]<<")="<< fixed<<setprecision(2)<<d[i]<<endl; return 0; }
64
31,742
int x[10],y[10],z[10],k=0,d[100]={0},e[100]={0},i,j,k,n; double c[100]={0},temp; int main() { scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { c[k]=sqrt( pow(x[i]-x[j],2)+ pow(y[i]-y[j],2)+pow(z[i]-z[j],2) ); d[k]=i; e[k]=j; k++; } } for(i=0;i<k;i++) { for(j=i+1;j<k;j++) { if(c[i]<c[j]) { temp=c[i];c[i]=c[j];c[j]=temp; temp=d[i];d[i]=d[j];d[j]=temp; temp=e[i];e[i]=e[j];e[j]=temp; } if( (c[i]==c[j])&& ((d[i]>d[j])||(e[i]>e[j]))) { temp=c[i];c[i]=c[j];c[j]=temp; temp=d[i];d[i]=d[j];d[j]=temp; temp=e[i];e[i]=e[j];e[j]=temp; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[d[i]],y[d[i]],z[d[i]],x[e[i]],y[e[i]],z[e[i]],c[i]); } return 0; }
64
31,743
// // main.cpp // ???? // // Created by ???? on 13-11-6. // Copyright (c) 2013? ????. All rights reserved. // int main() { int a[11][4]; int k=1; float b[100][3]; //input int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i][1]>>a[i][2]>>a[i][3]; } //end of input //the distence into b for(int i=1;i<n;i++) { for(int j=i+1;j<=n;j++) { double dis= (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][0]=sqrt(dis); b[k][1]=i; b[k][2]=j; k++; } } //sort for(int i=1;i<=k-1;i++) { for(int j=k-1;j>=i+1;j--) { if(b[j][0]>b[j-1][0]) { float t0=b[j][0]; b[j][0]=b[j-1][0]; b[j-1][0]=t0; int t1=b[j][1]; b[j][1]=b[j-1][1]; b[j-1][1]=t1; int t2=b[j][2]; b[j][2]=b[j-1][2]; b[j-1][2]=t2; } } } //cout<<b[1][0]<<' '<<b[2][0]<<endl; //cout for(int j=1;j<=k-1;j++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[ (int)b[j][1] ][1],a[ (int)b[j][1] ][2],a[ (int)b[j][1] ][3], a[ (int)b[j][2] ][1],a[ (int)b[j][2] ][2],a[ (int)b[j][2] ][3], b[j][0]); } return 0; }
64
31,744
int main(){ int n; int N=1000; scanf("%d",&n); int a[n];int b[n];int c[n];int d[n];int e[n];int f[n];int h[N];int q[N];int j[N];int v[N];int l[N];int o[N]; double g[N]; for(int i=1;i<=n;i++){ scanf("%d %d %d",&a[i-1],&b[i-1],&c[i-1]); d[i-1]=a[i-1];e[i-1]=b[i-1];f[i-1]=c[i-1]; } int x=0; for(int i=1;i<n;i++){ double p; int s; for(int t=i+1;t<=n;t++){ s=((a[i-1]-d[t-1])*(a[i-1]-d[t-1]))*1.0+((b[i-1]-e[t-1])*(b[i-1]-e[t-1]))*1.0+((c[i-1]-f[t-1])*(c[i-1]-f[t-1]))*1.0; p=sqrt(s)*1.0; g[x]=p;h[x]=a[i-1];q[x]=b[i-1];j[x]=c[i-1];v[x]=d[t-1];l[x]=e[t-1];o[x]=f[t-1]; x++; } } for(int k=1;k<=x;k++){ for(int m=1;m<=(x-k);m++){ if(g[m-1]<g[m]){double y;y=g[m-1];g[m-1]=g[m];g[m]=y; int s;s=h[m-1];h[m-1]=h[m];h[m]=s; s=q[m-1];q[m-1]=q[m];q[m]=s; s=j[m-1];j[m-1]=j[m];j[m]=s; s=v[m-1];v[m-1]=v[m];v[m]=s; s=l[m-1];l[m-1]=l[m];l[m]=s; s=o[m-1];o[m-1]=o[m];o[m]=s; } } } for(int z=1;z<=x;z++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",h[z-1],q[z-1],j[z-1],v[z-1],l[z-1],o[z-1],g[z-1]); } return 0; }
64
31,745
int main() { int n,m=0,a=0; float l=0; float D[50]; int X[11],Y[11],Z[11],p[50],q[50]; cin>>n; for(int i=0;i<n;i++) {cin>>X[i]; cin>>Y[i]; cin>>Z[i];//?x,y,z?????? } for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { D[m]=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]));//???????????????D? p[m]=i;// q[m]=j;//??????????????????? m++; } for(int i=m-1;i>0;i--) for(int j=0;j<i;j++) { if(D[j]<D[j+1]) { l=D[j]; D[j]=D[j+1]; D[j+1]=l; a=p[j]; p[j]=p[j+1]; p[j+1]=a; a=q[j]; q[j]=q[j+1]; q[j+1]=a; }//?????????,??????????????????? } for(int k=0;k<m;k++)//???????????? printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",X[p[k]],Y[p[k]],Z[p[k]],X[q[k]],Y[q[k]],Z[q[k]],D[k]); return 0; }
64
31,746
int main(){ int n,i,k,a,w,e; scanf("%d\n",&n); int x[n],y[n],z[n]; for(i=0;i<n;i++){ scanf("%d %d %d ",&x[i],&y[i],&z[i]); } double r,s,m[n*(n-1)/2],j; int p[n*(n-1)/2],q[n*(n-1)/2]; a=0; for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ r=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])); m[a]=r; p[a]=i; q[a]=k; a++; } } s=n*(n-1)/2; for(i=1;i<s;i++){ for(a=0;a<s-i;a++){ if(m[a]<m[a+1]){ j=m[a]; m[a]=m[a+1]; m[a+1]=j; w=p[a]; p[a]=p[a+1]; p[a+1]=w; e=q[a]; q[a]=q[a+1]; q[a+1]=e; } } } for(a=0;a<s;a++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p[a]],y[p[a]],z[p[a]],x[q[a]],y[q[a]],z[q[a]],m[a]); } return 0; }
64
31,747
/* * justexp.cpp * * Created on: 2011-11-18 * Author: dell */ int main() { int n,m,i,j,k,l; cin>>n; m=n*(n-1)/2; int point[n][3]; for(i=0;i<n;i++) cin>>point[i][0]>>point[i][1]>>point[i][2]; struct data { int point1[3]; int point2[3]; float len; int mark1; int mark2; }distance[m],temp; for(k=i=0;i<n-1;i++) for(j=i+1;j<n;j++,k++) { distance[k].len=0; for(l=0;l<3;l++) { distance[k].mark1=i; distance[k].mark2=j; distance[k].point1[l]=point[i][l]; distance[k].point2[l]=point[j][l]; distance[k].len+=(point[i][l]-point[j][l])*(point[i][l]-point[j][l]); } distance[k].len=sqrt(distance[k].len); } for(i=0;i<m-1;i++) for(j=i+1;j<m;j++) { if(distance[i].len<distance[j].len) { temp=distance[i]; distance[i]=distance[j]; distance[j]=temp; } if(distance[i].len==distance[j].len) { if((distance[i].mark1>distance[j].mark1)||((distance[i].mark1==distance[j].mark1)&&(distance[i].mark2>distance[j].mark2))) { temp=distance[i]; distance[i]=distance[j]; distance[j]=temp; } } } for(i=0;i<m;i++) { cout<<'('<<distance[i].point1[0]<<','<<distance[i].point1[1]<<','<<distance[i].point1[2]<<')'; cout<<'-'; cout<<'('<<distance[i].point2[0]<<','<<distance[i].point2[1]<<','<<distance[i].point2[2]<<')'; printf("=%.2f\n",distance[i].len); } return 0; }
64
31,748
struct pl { float s[3]; }; struct pl p[10]; struct place { struct pl y; struct pl x; float p; }; struct place q[45]; struct place qx; int main() { int n,m,i,j,k=0,l,r,v; scanf("%d",&n); m=n*(n-1)/2; for(i=0;i<=n-1;i++) { scanf("%f %f %f",&p[i].s[0],&p[i].s[1],&p[i].s[2]); } for(i=0;i<=n-1;i++) { for(j=i+1;j<=n-1;j++) { q[k].y=p[i]; q[k].x=p[j]; q[k].p=sqrt( (p[i].s[0]-p[j].s[0])*(p[i].s[0]-p[j].s[0])+(p[i].s[1]-p[j].s[1])*(p[i].s[1]-p[j].s[1])+(p[i].s[2]-p[j].s[2])*(p[i].s[2]-p[j].s[2]) ); k++; } } for(l=0;l<=m-1;l++) { for(r=0;r<=m-1-l;r++) { if(q[r].p<q[r+1].p) { qx=q[r]; q[r]=q[r+1]; q[r+1]=qx; } } } for(v=0;v<=m-1;v++) { printf("(%g,%g,%g)-(%g,%g,%g)=%.2lf\n",q[v].y.s[0],q[v].y.s[1],q[v].y.s[2],q[v].x.s[0],q[v].x.s[1],q[v].x.s[2],q[v].p); } }
64
31,749
struct point { int x; int y; int z; }; struct dist { struct point *p1; struct point *p2; double l; }; void sort(struct dist a[], int n) { int i,j; struct dist t; for(i=0;i<n-1;i++) for(j=n;j>i;j--) if(a[j].l>a[j-1].l) { t=a[j];a[j]=a[j-1];a[j-1]=t; } } void main() { struct point p[10]; struct dist d[50]; int n,i,j,c=0; 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[c].p1=&p[i]; d[c].p2=&p[j]; d[c].l=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)); c++; } sort(d,c); for(i=0;i<c;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].l); }
64
31,750
struct point { double x; double y; double z; }; struct dianju { double d; struct point p1; struct point p2; }; void main() { double julijisuan(struct point p1,struct point p2); int n,i,j,k; struct point p[m]; struct dianju D[m*(m-1)/2]; struct dianju a; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z); } for(i=0,k=0;i<n-1;i++) { for(j=i;j<n-1;j++,k++) { D[k].p1=p[i]; D[k].p2=p[j+1]; D[k].d=julijisuan(D[k].p1,D[k].p2); } } for(i=0;i<n*(n-1)/2;i++) { for(j=0;j<n*(n-1)/2-1;j++) { if(D[j].d<D[j+1].d) { a=D[j]; D[j]=D[j+1]; D[j+1]=a; } } } for(i=0;i<n*(n-1)/2;i++) { printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.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].d); } } double julijisuan(struct point p1,struct point p2) { return(sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z))); }
64
31,751
float sqr(float x) { float ans; ans=x*x;return(ans); } float work(float a[3],float b[3]) { float ans; ans=sqrt(sqr(a[0]-b[0])+sqr(a[1]-b[1])+sqr(a[2]-b[2])); return(ans); } int main() { int n,i,j,x,num; int a[101][3]={0}; float dis[101]={0},d[11][3],x1; scanf("%d",&n); for (i=0;i<n;i++) for (j=0;j<3;j++) scanf("%f",&d[i][j]); num=0; for (i=0;i<n;i++) for (j=i+1;j<n;j++) {dis[num]=work(d[i],d[j]);a[num][1]=i;a[num][2]=j;num++;} for (i=0;i<num-1;i++) for (j=0;j<num-1;j++) if (dis[j]<dis[j+1]) {x1=dis[j];dis[j]=dis[j+1];dis[j+1]=x1; x=a[j][1];a[j][1]=a[j+1][1];a[j+1][1]=x; x=a[j][2];a[j][2]=a[j+1][2];a[j+1][2]=x;} for (i=0;i<num;i++) {x=a[i][1];j=a[i][2]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",(int)d[x][0],(int)d[x][1],(int)d[x][2],(int)d[j][0],(int)d[j][1],(int)d[j][2],dis[i]);} }
64
31,752
//*********************************** //** ???Dec 11, 2013 - ???? ** //** ?????? 1300012719 ** //** ???2013.12.14 ** //*********************************** int main() { int i, j, k = 0, n; //k???n???????? struct p //???p???????? { int x; int y; int z; } p[10]; struct ptp //???ptp?????????????????,?????45,????????????? { int x1; int y1; int z1; int x2; int y2; int z2; double dis; } ptp[46]; 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++) { ptp[k].x1 = p[i].x; ptp[k].x2 = p[j].x; ptp[k].y1 = p[i].y; ptp[k].y2 = p[j].y; ptp[k].z1 = p[i].z; ptp[k].z2 = p[j].z; ptp[k].dis = sqrt((ptp[k].x1-ptp[k].x2) * (ptp[k].x1-ptp[k].x2) + (ptp[k].y1-ptp[k].y2) * (ptp[k].y1-ptp[k].y2) + (ptp[k].z1-ptp[k].z2) * (ptp[k].z1-ptp[k].z2)); k++; } for (i = 0; i < k - 1; i++) //??????ptp[45],?????????ptp??????? for (j = 0; j < k - 1 - i; j++ ) { if (ptp[j].dis < ptp[j + 1].dis) { ptp[45] = ptp[j]; ptp[j] = ptp[j + 1]; ptp[j + 1] = ptp[45]; } } for (i = 0; i < k; i++) //??????????? cout << "(" << ptp[i].x1 << "," << ptp[i].y1 << "," << ptp[i].z1 << ")-(" << ptp[i].x2 << "," << ptp[i].y2 << "," << ptp[i].z2 << ")=" << fixed << setprecision(2) << ptp[i].dis << endl; return 0; }
64
31,753
struct dot { int x; int y; int z; }point[10]; int main() { int n,i,j,k,l,t=0,s=0; float a[10][10]={0},tem,b[50]={0}; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].z); s=s+i; } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { a[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)); b[t]=a[i][j]; t++; } for(i=0;i<s-1;i++) for(j=0;j<s-i-1;j++) { if(b[j]<b[j+1]) { tem=b[j]; b[j]=b[j+1]; b[j+1]=tem; } } for(k=0;k<s;k++) { if(b[k]==b[k-1]) continue; else { for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { if(a[i][j]==b[k]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",point[i].x,point[i].y,point[i].z,point[j].x,point[j].y,point[j].z,b[k]); } } } return 0; }
64
31,754
const int N=10; int n,m,x[N],y[N],z[N]; int p1[N*N/2],p2[N*N/2]; int main() { cin>>n; for (int i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i]; m=0; for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) { p1[m]=i; p2[m++]=j; } for (int i=0;i<m;i++) for (int j=0;j<m-1;j++) { //int &c1=p1[j],&c2=p2[j],&d1=p1[j+1],&d2=p2[j+1]; int c1=p1[j],c2=p2[j],d1=p1[j+1],d2=p2[j+1]; if ((x[c1]-x[c2])*(x[c1]-x[c2])+(y[c1]-y[c2])*(y[c1]-y[c2])+(z[c1]-z[c2])*(z[c1]-z[c2])< (x[d1]-x[d2])*(x[d1]-x[d2])+(y[d1]-y[d2])*(y[d1]-y[d2])+(z[d1]-z[d2])*(z[d1]-z[d2])) { /*int temp; temp=c1; c1=d1; d1=temp; temp=c2; c2=d2; d2=temp;*/ int temp; temp=p1[j]; p1[j]=p1[j+1]; p1[j+1]=temp; temp=p2[j]; p2[j]=p2[j+1]; p2[j+1]=temp; } } for (int i=0;i<m;i++) { int c1=p1[i],c2=p2[i]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[c1],y[c1],z[c1],x[c2],y[c2],z[c2],sqrt(((double)x[c1]-(double)x[c2])*((double)x[c1]-(double)x[c2])+((double)y[c1]-(double)y[c2])*((double)y[c1]-(double)y[c2])+((double)z[c1]-(double)z[c2])*((double)z[c1]-(double)z[c2]))); } return 0; }
64
31,755
void main() { char *p; int a[12][3], n,i,j,t=1; double b[50][3],temp; p="%d%d%d"; scanf("%d",&n); for(i=1;i<=n;i++) { scanf(p,&a[i][0],&a[i][1],&a[i][2]); } for(i=1;i<=n-1;i++) for(j=i+1;j<=n;j++) { b[t][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)); b[t][1]=i; b[t][2]=j; t++; } for(i=1;i<t-1;i++) for(j=1;j<t-i;j++) { if(b[j][0]<b[j+1][0]) { temp=b[j+1][0]; b[j+1][0]=b[j][0]; b[j][0]=temp; temp=b[j+1][1]; b[j+1][1]=b[j][1]; b[j][1]=temp; temp=b[j+1][2]; b[j+1][2]=b[j][2]; b[j][2]=temp; } } for(i=1;i<t;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[(int)(b[i][1])][0],a[(int)(b[i][1])][1],a[(int)(b[i][1])][2],a[(int)(b[i][2])][0],a[(int)(b[i][2])][1],a[(int)(b[i][2])][2],b[i][0]); }
64
31,756
int main() { struct address { int x; int y; int z; }point[10]; int n,i,j,k; double d[45],t; 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++) d[(2*n-1-i)*i/2+j-i-1]=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<n*(n-1)/2-1;i++) { for(j=i+1;j<n*(n-1)/2;j++) { if(d[j]>d[i]) {t=d[i];d[i]=d[j];d[j]=t;} } } for(i=0;i<n*(n-1)/2;) { for(j=0;j<n-1;j++) { for(k=j+1;k<n;k++) { if(sqrt((point[k].x-point[j].x)*(point[k].x-point[j].x)+(point[k].y-point[j].y)*(point[k].y-point[j].y)+(point[k].z-point[j].z)*(point[k].z-point[j].z))==d[i]) {cout<<"("<<point[j].x<<","<<point[j].y<<","<<point[j].z<<")-("<<point[k].x<<","<<point[k].y<<","<<point[k].z<<")="; cout<<(fixed)<<setprecision(2)<<d[i]<<endl;} } } for(j=i+1;j<n*(n-1)/2;j++) { if(d[j]!=d[i]) break; } i=j; } return 0; }
64
31,757
int main() { int a[11][3],i,j,n,k,c[46],d[46],f; double b[46],t; cin>>n; for(i=1;i<=n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; } k=1; for(i=1;i<n;i++) for(j=i+1;j<=n;j++) { b[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]) ); c[k]=i; d[k]=j; k++; } f=n*(n-1)/2; for(i=1;i<f;i++) for(j=f-1;j>=i;j--) { if(b[j]<b[j+1]) { t=b[j]; b[j]=b[j+1]; b[j+1]=t; t=c[j]; c[j]=c[j+1]; c[j+1]=t; t=d[j]; d[j]=d[j+1]; d[j+1]=t; } } for(i=1;i<f;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]<<")="<<fixed<<setprecision(2)<<b[i]<<endl; cout<<'('<<a[c[f]][0]<<','<<a[c[f]][1]<<','<<a[c[f]][2]<<")-("<<a[d[f]][0]<<','<<a[d[f]][1]<<','<<a[d[f]][2]<<")="<<fixed<<setprecision(2)<<b[f]; return 0; }
64
31,758
struct { int x,y,z; }a[12]; struct { int x1,x2,y1,y2,z1,z2; double l; }dis[120],t; void sort(int a) { for (int i=0; i<a; i++) for (int j=0; j<a-1-i; j++) { if (dis[j].l < dis[j+1].l) { t= dis[j]; dis[j] = dis[j+1]; dis[j+1] = t; } } for (int i=0; i<a; i++) { cout << "(" << dis[i].x1 << "," << dis[i].y1 << "," << dis[i].z1 << ")-(" << dis[i].x2 << "," << dis[i].y2 << "," << dis[i].z2 << ")=" << fixed << setprecision(2) << dis[i].l <<endl; } } int main() { int n; cin >> n; for (int i=0; i<n; i++) { cin >> a[i].x >> a[i].y >> a[i].z ; } int count = 0; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { dis[count].l = sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y) *(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); dis[count].x1 = a[i].x; dis[count].x2 = a[j].x; dis[count].y1 = a[i].y; dis[count].y2 = a[j].y; dis[count].z1 = a[i].z; dis[count].z2 = a[j].z; count++; } } sort (count); cin >> n; return 0; }
64
31,759
const double EPS=1e-6; int main() { int a[10][3],c[50],n,z=0; cin>>n; for(int i=0;i<50;++i) {c[i]=i;} for(int i=0;i<n;++i) {cin>>a[i][0]>>a[i][1]>>a[i][2];} struct MyStruct { double d; int x; int y; }b[50]; for(int i=0;i<n;++i) for(int j=i+1;j<n;++j) { b[z].d =floor((100*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])))+0.5)/100; b[z].x=i; b[z].y=j; ++z; } for(int i=0;i<n*(n-1)/2;++i) for(int j=0;i+j<n*(n-1)/2-1;++j) { if((b[c[j+1]].d - b[c[j]].d)> EPS) { int temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; } else if((fabs(b[c[j+1]].d - b[c[j]].d)<EPS)) { if(b[c[j+1]].x<b[c[j]].x) { int temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; } } } for(int i=0;i<n*(n-1)/2;++i) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[b[c[i]].x][0],a[b[c[i]].x][1],a[b[c[i]].x][2],a[b[c[i]].y][0],a[b[c[i]].y][1],a[b[c[i]].y][2],b[c[i]].d); } return 0; }
64
31,760
int main() { struct point { int x,y,z; }; struct point p[10]; struct distance { struct point p1; struct point p2; float dis; }; struct distance d[45]; struct distance temp; int i,n,j,k; float pf; scanf("%d",&n); k=0; 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[k].p1=p[i]; d[k].p2=p[j]; pf=(float)(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].dis=sqrt(pf); k++; } } for(i=0;i<n*(n-1)/2-1;i++) { for(j=0;j<n*(n-1)/2-i;j++) { if(d[j].dis<d[j+1].dis) { temp=d[j]; d[j]=d[j+1]; d[j+1]=temp; } } } for(i=0;i<n*(n-1)/2;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\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].dis); } return 0; }
64
31,761
int main(){ int x[1000],y[1000],z[1000],n,i,m,j,u[1000],v[1000],c,d; double s[100],b; b=0; c=0; d=0; m=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;i++){ for(j=n-1;j>i;j--){ b=(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[m]= sqrt(b); u[m]=i; v[m]=j; m++; } } for(i=0;i<n*(n-1)/2;i++){ if(n==2) break; for(j=0;j<n*(n-1)/2;j++){ if(s[j]<s[j+1]){ b=s[j]; s[j]=s[j+1]; s[j+1]=b; c=u[j]; u[j]=u[j+1]; u[j+1]=c; d=v[j]; v[j]=v[j+1]; v[j+1]=d; } } } for(i=0;i<n*(n-1)/2;i++){ if(n==2) break; if(s[i]==s[i+1]){ if(u[i]>u[i+1]){ c=u[i]; u[i]=u[i+1]; u[i+1]=c; d=v[i]; v[i]=v[i+1]; v[i+1]=d; } if(u[i]==u[i+1]){ if(v[i]>v[i+1]){ c=u[i]; u[i]=u[i+1]; u[i+1]=c; d=v[i]; v[i]=v[i+1]; v[i+1]=d; } } } } for(i=0;i<n*(n-1)/2;i++){ if(n==2) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[u[0]],y[u[0]],z[u[0]],x[v[0]],y[v[0]],z[v[0]],s[0]); else{ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[u[i]],y[u[i]],z[u[i]],x[v[i]],y[v[i]],z[v[i]],s[i]); } } return 0; }
64
31,762
struct distant { int x1; int x2; float dis; }; float dist(int x[],int y[]) { float d; d=(x[0]-y[0])*(x[0]-y[0])+(x[1]-y[1])*(x[1]-y[1])+(x[2]-y[2])*(x[2]-y[2]); d=sqrt(d); return d; } int main() { int n; int x[10][3]; struct distant d[50],temp; scanf("%d",&n); int i,j,k; for(i=0;i<n;i++) { for(j=0;j<3;j++)scanf("%d",&x[i][j]); } for(i=0,k=0;i<n;i++) { for(j=i+1;j<n;j++,k++){d[k].x1=i;d[k].x2=j;d[k].dis=dist(x[i],x[j]);} } for(i=1;i<k;i++) { for(j=0;j<k-i;j++)if(d[j].dis<d[j+1].dis){temp=d[j];d[j]=d[j+1];d[j+1]=temp;} } for(i=0;i<k;i++)printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[d[i].x1][0],x[d[i].x1][1],x[d[i].x1][2],x[d[i].x2][0],x[d[i].x2][1],x[d[i].x2][2],d[i].dis); }
64
31,763
int main() { int x[20] = {0}, y[20] = {0}, z[20] = {0}, n, flag1[200], flag2[200], i, j, k = 1, p; double distance[200], t; cin >> n; for (i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> z[i]; } for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++, k++) { distance[k] = sqrt(pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0) + pow(z[i] - z[j], 2.0)); flag1[k] = i; flag2[k] = j; } } for (k = 1; k <= n * (n - 1) / 2; k++) { for (i = 1; i <= n * (n - 1) / 2 + 1 - k; i++) { if (distance[i] < distance[i + 1]) { t = distance[i]; distance[i] = distance[i + 1]; distance[i + 1] = t; p = flag1[i]; flag1[i] = flag1[i + 1]; flag1[i + 1] = p; p = flag2[i]; flag2[i] = flag2[i + 1]; flag2[i + 1] = p; } } } for (i = 1; i <= n * (n - 1) / 2; i++) { cout << "(" << x[flag1[i]] << "," << y[flag1[i]] << "," << z[flag1[i]] << ")-(" << x[flag2[i]] << "," << y[flag2[i]] << "," << z[flag2[i]] << ")=" << fixed << setprecision(2) << distance[i] << endl; } return 0; }
64
31,764
struct distance { double length; int start; int end; }; main() { int n; scanf("%d",&n); int point[10][4]; int i,j; struct distance dist[45]; for (i=0;i<n;i++) scanf("%d %d %d",&point[i][1],&point[i][2],&point[i][3]); int k=0; for (i=0;i<n-1;i++) for (j=i+1;j<n;j++) { dist[k].length=sqrt((point[i][1]-point[j][1])*(point[i][1]-point[j][1])+(point[i][2]-point[j][2])*(point[i][2]-point[j][2])+(point[i][3]-point[j][3])*(point[i][3]-point[j][3])); dist[k].start=i; dist[k].end=j; k++; } double temp; int temp1; for (i=0;i<k-1;i++) for (j=0;j<k-1-i;j++) if (dist[j].length<dist[j+1].length) { temp=dist[j].length; dist[j].length=dist[j+1].length; dist[j+1].length=temp; temp1=dist[j].start; dist[j].start=dist[j+1].start; dist[j+1].start=temp1; temp1=dist[j].end; dist[j].end=dist[j+1].end; dist[j+1].end=temp1; } for (i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",point[dist[i].start][1],point[dist[i].start][2],point[dist[i].start][3],point[dist[i].end][1],point[dist[i].end][2],point[dist[i].end][3],dist[i].length); } getchar();getchar(); }
64
31,765
int main() { int n,a[10],b[10],c[10],num1,num2,m[50],l[50]; double d[50],temp,distance; int i,j,k=0; 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++) { distance=sqrt(pow((a[i]-a[j]),2)+pow((b[i]-b[j]),2)+pow((c[i]-c[j]),2)); d[k]=distance; m[k]=i; l[k]=j; k++; } } for(i=1;i<=n*(n-1)/2;i++){ for(j=0;j<n*(n-1)/2-i;j++){ if(d[j]<d[j+1]) { temp=d[j]; d[j]=d[j+1]; d[j+1]=temp; num1=m[j]; m[j]=m[j+1]; m[j+1]=num1; num2=l[j]; l[j]=l[j+1]; l[j+1]=num2; } } } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[m[i]],b[m[i]],c[m[i]],a[l[i]],b[l[i]],c[l[i]],d[i]); } return 0; }
64
31,766
int main() { int n,i,j,k=0,l; double a[102][4],b[102][102],c[2000]={0}; 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++) { b[i][j]=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])); c[k]=b[i][j]; k++; } } sort(c,c+n*(n-1)/2); for(k=n*(n-1)/2-1;k>=0;k--) {if(c[k+1]==c[k])continue; for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { if(b[i][j]==c[k]) {cout<<"("<<a[i][1]<<","<<a[i][2]<<","<<a[i][3]<<")-("<<a[j][1]<<","<<a[j][2]<<","<<a[j][3]<<")="; printf("%.2f",c[k]); cout<<endl;} } } } return 0; }
64
31,767
int main(){ int n=0; cin>>n; int dis[10][3]; float ans[1000][7]; for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ cin>>dis[i][j]; } } int num=0; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ for(int k=0;k<3;k++){ ans[num][k]=dis[i][k]; } for(int k=0;k<3;k++){ ans[num][k+3]=dis[j][k]; } ans[num][6]=0.0; for(int k=0;k<3;k++){ ans[num][6]+=(dis[i][k]-dis[j][k])*(dis[i][k]-dis[j][k]); } ans[num][6]=sqrt(ans[num][6]); num++; } } for(int i=0;i<num;i++){ for(int j=num-1;j>i;j--){ if(ans[j][6]>ans[j-1][6]){ for(int k=0;k<7;k++){ float tmp=ans[j][k]; ans[j][k]=ans[j-1][k]; ans[j-1][k]=tmp; } } } } for(int i=0;i<num;i++){ cout<<'('<<ans[i][0]<<','<<ans[i][1]<<','<<ans[i][2]<<")-("<<ans[i][3]<<','<<ans[i][4]<<','<<ans[i][5]<<")="; printf("%.2f",ans[i][6]); if(i<num-1) cout<<endl; } return 0; }
64
31,768
int main(){ int n,i,k,s,m; int zb[10][3]; double d[45][7],e; scanf("%d",&n); for(i=0;i<n;i++){ for(s=0;s<3;s++){ scanf("%d",&(zb[i][s])); } } s=0; for(i=0;i<=n-2;i++){ for(k=1;i+k<=n-1;k++){ m=(zb[i][0]-zb[i+k][0])*(zb[i][0]-zb[i+k][0])+(zb[i][1]-zb[i+k][1])*(zb[i][1]-zb[i+k][1])+(zb[i][2]-zb[i+k][2])*(zb[i][2]-zb[i+k][2]); d[s][0]=sqrt(m); d[s][1]=zb[i][0]; d[s][2]=zb[i][1]; d[s][3]=zb[i][2]; d[s][4]=zb[i+k][0]; d[s][5]=zb[i+k][1]; d[s][6]=zb[i+k][2]; s++; } } m=s; for(k=1;m-k>0;k++){ for(i=0;i<m-k;i++){ if(d[i][0]<d[i+1][0]){ for(s=0;s<7;s++){ e=d[i][s]; d[i][s]=d[i+1][s]; d[i+1][s]=e; } } } } for(i=0;i<m;i++){ printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",d[i][1],d[i][2],d[i][3],d[i][4],d[i][5],d[i][6],d[i][0]); } return 0; }
64
31,769
int main() { int n=0; cin>>n; double an[100][3]; int i=0,j=0; for(i=0;i<n;i++) for(j=0;j<3;j++) cin>>an[i][j]; struct { int i; int j; double dis; }stu[1000],t; int k=0,m=0,p=0; for(m=0;m<n;m++) { for(p=m+1;p<n;p++) { stu[k].i=m; stu[k].j=p; double mm=(an[m][0]-an[p][0])*(an[m][0]-an[p][0])+(an[m][1]-an[p][1])*(an[m][1]-an[p][1])+(an[m][2]-an[p][2])*(an[m][2]-an[p][2]); stu[k].dis=sqrt(mm); k++; } } for(int q=0;q<k;q++) for(int qq=q+1;qq<k;qq++) { if((stu[q].dis<stu[qq].dis)||(stu[q].dis==stu[qq].dis)&&((stu[q].i>stu[qq].i)||(stu[q].i==stu[qq].i)&&(stu[q].j>stu[qq].j))) { t=stu[qq]; stu[qq]=stu[q]; stu[q]=t; } } for(int r=0;r<k;r++) cout<<fixed << setprecision(0)<<"("<<an[stu[r].i][0]<<","<<an[stu[r].i][1]<<","<<an[stu[r].i][2]<<")-("<<an[stu[r].j][0]<<","<<an[stu[r].j][1]<<","<<an[stu[r].j][2]<<")="<<fixed << setprecision(2)<<stu[r].dis<<endl; return 0; }
64
31,770
struct point { int x; int y; int z; } p[100]; struct line { int p1; int p2; double len; } l[1000], t; int main() { int n, i, j, d[1000], c = 0; double temp; cin >> n; for (i = 0; i < n; i++) { cin >> p[i].x >> p[i].y >> p[i].z; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { l[c].len = 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)); l[c].p1 = i; l[c].p2 = j; c++; } } for (i = 0; i < n * (n - 1) / 2; i++) { for (j = 0; j < n * (n - 1) / 2 - i; j++) { if (l[j].len < l[j + 1].len ) { t = l[j]; l[j] = l[j + 1]; l[j + 1] = t; } } } for (i = 0; i < n * (n - 1) / 2; i++) { cout << "(" << p[l[i].p1].x << "," << p[l[i].p1].y << "," << p[l[i].p1].z << ")-(" << p[l[i].p2].x << "," << p[l[i].p2].y << "," << p[l[i].p2].z << ")=" << fixed << setprecision(2) << l[i].len << setprecision(0) << endl; } return 0; }
64
31,771
int main() { struct point { int NO;//???? double x;double y;double z;//???? double d[10];//?????? }points[10]; //??????? ? ??? struct data { int num; int fromx;int fromy;int fromz; int tox;int toy;int toz; double dd; }result[45+5],temp; //??????? ?? ??? int n; cin>>n; //???? for(int i=0;i<=n-1;i++) { points[i].NO=i+1; cin>>points[i].x>>points[i].y>>points[i].z; } //????? int k=0; int end; for(int i=0;i<=n-2;i++) for(int j=i+1;j<=n-1;j++) { result[++k].dd=points[i].d[j]=sqrt((points[i].x-points[j].x)*(points[i].x-points[j].x)+ (points[i].y-points[j].y)*(points[i].y-points[j].y)+ (points[i].z-points[j].z)*(points[i].z-points[j].z)); result[k].fromx=(int)points[i].x; result[k].fromy=(int)points[i].y; result[k].fromz=(int)points[i].z; result[k].tox=(int)points[j].x; result[k].toy=(int)points[j].y; result[k].toz=(int)points[j].z; result[k].num=k; end=k; } //??????? for(int i=1;i<=end;i++) for(int j=i;j<=end;j++) { if(result[i].dd<result[j].dd) { temp=result[i]; result[i]=result[j]; result[j]=temp; } } //????????? for(int i=1;i<=end;i++) for(int j=i;j<=end;j++) { if(result[i].dd==result[j].dd&&result[i].num>result[j].num) { temp=result[i]; result[i]=result[j]; result[j]=temp; } } //???????????? for(int i=1;i<=end;i++) { cout<<"("<<result[i].fromx<<","<<result[i].fromy<<","<<result[i].fromz<<")-(" <<result[i].tox<<","<<result[i].toy<<","<<result[i].toz<<")=" <<fixed<<setprecision(2)<<result[i].dd<<endl; } //?? return 0; }
64
31,772
int main(){ int n,c,a,b,i,o,p,k; double e; scanf("%d",&n); double jl[n][n]; int x[n],y[n],z[n]; k=n*(n-1)/2; for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(a=0;a<n;a++){ b=a+1; while(b<n){ jl[a][b]=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])); b++; } } e=0; for(i=0;i<k;i++){ for(a=0;a<n;a++){ b=a+1; while(b<n){ if(e<jl[a][b]){ e=jl[a][b]; o=a; p=b; } b++; } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[o],y[o],z[o],x[p],y[p],z[p],e); jl[o][p]=0; e=0; } return 0; }
64
31,773
int main(){ int n,y; scanf("%d\n",&n); int x[n][3]; double jl[10][10],o; for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i][0],&x[i][1],&x[i][2]); } for(int i=0;i<n-1;i++){ for(int k=i+1;k<n;k++){ jl[i][k]=0; } } for(int i=0;i<n-1;i++){ for(int k=i+1;k<n;k++){ jl[i][k]=sqrt((x[i][0]-x[k][0])*(x[i][0]-x[k][0])+(x[i][1]-x[k][1])*(x[i][1]-x[k][1])+(x[i][2]-x[k][2])*(x[i][2]-x[k][2])); } } o=0; int m,p,q,a=0; m=n*(n-1)/2; for(int i=0;i<9;i++){ if(a==m){ break; } for(int k=i+1;k<10;k++){ if(o<jl[i][k]){ o=jl[i][k]; p=i; q=k; } if(i==8&&k==9){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p][0],x[p][1],x[p][2],x[q][0],x[q][1],x[q][2],o); jl[p][q]=0; i=-1; o=0; a++; } } } return 0; }
64
31,774
struct point { int x; int y; int z; } p[100]; struct line { int p1; int p2; double len; } l[1000]; int main() { int n, i, j, d[1000], c = 0; double temp; cin >> n; for (i = 0; i < n; i++) { cin >> p[i].x >> p[i].y >> p[i].z; } for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { l[c].len = 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)); l[c].p1 = i; l[c].p2 = j; c++; } } for (i = 0; i < n * (n - 1) / 2; i++) { for (j = 0; j < n * (n - 1) / 2 - i; j++) { if (l[j].len < l[j + 1].len ) { temp = l[j].len; l[j].len = l[j + 1].len; l[j + 1].len = temp; temp = l[j].p1; l[j].p1 = (int) l[j + 1].p1; l[j + 1].p1 =(int) temp; temp = l[j].p2; l[j].p2 = (int) l[j + 1].p2; l[j + 1].p2 =(int) temp; } } } for (i = 0; i < n * (n - 1) / 2; i++) { cout << "(" << p[l[i].p1].x << "," << p[l[i].p1].y << "," << p[l[i].p1].z << ")-(" << p[l[i].p2].x << "," << p[l[i].p2].y << "," << p[l[i].p2].z << ")=" << fixed << setprecision(2) << l[i].len << setprecision(0) << endl; } return 0; }
64
31,775
/* * pl.cpp * * Created on: 2013-11-2 * Author: lenovo */ const int maxN=105; int x[maxN],y[maxN],z[maxN],dis[maxN][maxN],d[maxN*maxN]={0}; int n; int calc(int a,int b) { return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*((y[a]-y[b]))+(z[a]-z[b])*(z[a]-z[b]); } int main() { int i,j; cin>>n; for(i=1;i<=n;i++){ cin>>x[i]>>y[i]>>z[i]; dis[i][i]=0; for(j=1;j<i;j++){ dis[i][j]=dis[j][i]=calc(i,j); d[++d[0]]=dis[i][j]; } } sort(d+1,d+d[0]+1); d[d[0]+1]=-1; for(int k=d[0];k;k--) if(d[k]!=d[k+1]){ for(i=1;i<n;i++) for(j=i+1;j<=n;j++) if(dis[i][j]==d[k]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[i],y[i],z[i],x[j],y[j],z[j],sqrt(dis[i][j])); } return 0; }
64
31,776
int main(){ int k[10][3],t; int n,i,j,a,b,g[100]; double h[100],e; scanf("%d",&n); for(i=0;i<100;i++){ g[i]=i; } for(i=0;i<100;i++){ h[i]=-1; } for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&k[i][j]); } } for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ h[i*n+j]=1.0*sqrt((k[i][0]-k[j][0])*(k[i][0]-k[j][0])+(k[i][1]-k[j][1])*(k[i][1]-k[j][1])+(k[i][2]-k[j][2])*(k[i][2]-k[j][2])); } } for(i=0;i<100;i++){ for(j=99;j>i;j--){ if(h[j-1]<h[j]){ t=g[j]; g[j]=g[j-1]; g[j-1]=t; e=h[j]; h[j]=h[j-1]; h[j-1]=e; } } } for(i=0;i<100;i++){ if(h[i]!=-1){ a=g[i]/n; b=g[i]%n; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",k[a][0],k[a][1],k[a][2],k[b][0],k[b][1],k[b][2],h[i]); } } return 0; }
64
31,777
double distance(double q,double w,double e,double r,double t,double y); int main(){ int a,b,e,f,g,h,n,i; double d[10][10],c; struct z { double j; double k; double l; } s[10]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%lf%lf%lf",&s[i].j,&s[i].k,&s[i].l); } for(a=0;a<n-1;a++){ for(b=a+1;b<n;b++){ d[a][b]=distance(s[a].j,s[a].k,s[a].l,s[b].j,s[b].k,s[b].l); } } for(e=n*(n-1)/2;e>0;e=e-1){ for(a=0,c=0;a<n-1;a++){ for(b=a+1;b<n;b++){ if(c<d[a][b]){ c=d[a][b]; f=a; g=b; } } } d[f][g]=0; printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",s[f].j,s[f].k,s[f].l,s[g].j,s[g].k,s[g].l,c); } return 0; } double distance(double q,double w,double e,double r,double t,double y){ double u; u=sqrt((q-r)*(q-r)+(w-t)*(w-t)+(e-y)*(e-y)); return u; }
64
31,778
int main() { int n,a[1000][3],i,j,x,e; double jl[1000][1000],m,k; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]); } k=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ m=(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]); jl[i][j]=sqrt(1.0*m); if(k<jl[i][j]){ k=jl[i][j]; } } } for(x=1;x<=n*(n-1)/2;x++){ e=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(k==jl[i][j] && e==0){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],a[j][0],a[j][1],a[j][2],jl[i][j]); jl[i][j]=0; k=0; e=1; } } } for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(k<jl[i][j]){ k=jl[i][j]; } } } } return 0; }
64
31,779
struct dist { int x; int y; int z; }; main() { struct dist a[11]; int n; scanf("%d",&n); int i,j,k; for(i=0;i<n;i++) { scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].z); } float d[10][10]; for(i=1;i<=n-1;i++) { for(j=0;j<i;j++) { d[i][j]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); } } float t; int fx1,fx2,fy1,fy2,fz1,fz2,i0,j0; k=n*(n-1)/2; while(k!=0) {t=0.0; for(i=0;i<n;i++) { for(j=0;j<i;j++) { if(d[i][j]>t) { t=d[i][j];i0=i;j0=j; fx1=a[j].x;fy1=a[j].y;fz1=a[j].z;fx2=a[i].x;fy2=a[i].y;fz2=a[i].z;} } } d[i0][j0]=0; printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",fx1,fy1,fz1,fx2,fy2,fz2,t); k--; } getchar(); getchar(); }
64
31,780
int main() { int n,i,j,e,c=0,a[10],b[10],d[10]; double s[100],t; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&d[i]); for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ s[c]=sqrt(1.0*(a[i]-a[j])*(a[i]-a[j])+1.0*(b[i]-b[j])*(b[i]-b[j])+1.0*(d[i]-d[j])*(d[i]-d[j])); c++; } } for(e=1;e<=n*(n-1)/2;e++){ for(c=0;c<n*(n-1)/2-e;c++){ if(s[c]<s[c+1]){ t=s[c+1]; s[c+1]=s[c]; s[c]=t; } } } for(c=0;c<n*(n-1)/2;c++){ if(s[c]==s[c+1]) continue; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(s[c]==sqrt(1.0*(a[i]-a[j])*(a[i]-a[j])+1.0*(b[i]-b[j])*(b[i]-b[j])+1.0*(d[i]-d[j])*(d[i]-d[j]))){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],d[i],a[j],b[j],d[j],s[c]); } } } } return 0; }
64
31,781
// ???? ?? 1000062708 int main() { struct num { int x; int y; int z; }a[10]; int i, j, k, n, xx, yy; double b[10][10], m = 0; cin >> n; for(i = 0;i < n;i++) cin >> a[i].x >> a[i].y >> a[i].z; for(i = 0;i < n;i++) for(j = i + 1;j < n;j++) b[i][j] = sqrt((double)(a[i].x - a[j].x) * (a[i].x - a[j].x) + (double)(a[i].y - a[j].y) * (a[i].y - a[j].y) + (double)(a[i].z - a[j].z) * (a[i].z - a[j].z)); for(k = 0;k < n * (n - 1) / 2;k++) { m = 0; for(i = 0;i < n;i++) for(j = i + 1;j < n;j++) { if(b[i][j] > m) { xx = i; yy = j; m = b[i][j]; } } cout << "(" << a[xx].x << "," << a[xx].y << "," << a[xx].z << ")-(" << a[yy].x << "," << a[yy].y << "," << a[yy].z << ")=" << fixed << setprecision(2) << m << endl; b[xx][yy] = 0; } return 0; }
64
31,782
double distance(int x1, int y1, int z1, int x2, int y2, int z2){ double q,s; q=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2); s=sqrt(q); return s; } int main(){ int n,k,i,j,x[10],y[10],z[10]; double sz[46][7]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i], &y[i], &z[i]); } k=0; for(i=0;i<n-1;i++){ for(j=i;j<n-1;j++){ sz[k][0]=x[i]*1.0; sz[k][1]=y[i]*1.0; sz[k][2]=z[i]*1.0; sz[k][3]=x[j+1]*1.0; sz[k][4]=y[j+1]*1.0; sz[k][5]=z[j+1]*1.0; sz[k][6]=distance(x[i],y[i],z[i],x[j+1],y[j+1],z[j+1]); k++; } } for(i=0;i<k-1;i++){ for(j=0;j<k-i-1;j++){ if(sz[j][6]<sz[j+1][6]){ sz[45][0]=sz[j+1][0]; sz[45][1]=sz[j+1][1]; sz[45][2]=sz[j+1][2]; sz[45][3]=sz[j+1][3]; sz[45][4]=sz[j+1][4]; sz[45][5]=sz[j+1][5]; sz[45][6]=sz[j+1][6]; sz[j+1][0]=sz[j][0]; sz[j+1][1]=sz[j][1]; sz[j+1][2]=sz[j][2]; sz[j+1][3]=sz[j][3]; sz[j+1][4]=sz[j][4]; sz[j+1][5]=sz[j][5]; sz[j+1][6]=sz[j][6]; sz[j][0]=sz[45][0]; sz[j][1]=sz[45][1]; sz[j][2]=sz[45][2]; sz[j][3]=sz[45][3]; sz[j][4]=sz[45][4]; sz[j][5]=sz[45][5]; sz[j][6]=sz[45][6]; } } } for(i=0;i<k;i++){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",sz[i][0], sz[i][1], sz[i][2], sz[i][3], sz[i][4], sz[i][5], sz[i][6]); } return 0; }
64
31,783
int main() { int a[10][3] = {0} ; //a[10][3]?????????? double b[45] = {0}; // b[45]???????????? int biaoji[45][2] = {0} ; //biaoji[45][2]??????????????? int n = 0 , i = 0 , j = 0 , k = 0 ; //n??????i,j,k????? cin >> n ; //?????? for ( i = 0 ; i < n ; i++ ) //???????????? for ( j = 0 ; j < 3 ; j++ ) cin >> a[i][j] ; for (i = 0 ; i < n ; i++ ) //????????????????? { for(j = i+1 ; j <n; j++ ) { b[k]= sqrt( (double) ( 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] ) ) ; //???? biaoji[k][0] = i ; //????????? biaoji[k][1] = j ; //??????????????i,j??????????????????????? k++ ; } } for ( i = 0 ; i < n * ( n - 1 ) / 2 ; i++ ) //?????????????????????????????? { //??????????????????????????????????????????????????? for( j = 0 ; j < n * ( n - 1 ) / 2 - i - 1 ; j++ ) { if ( b[j+1] - b[j] > 1e-4 ) //????double?????????????????b[j]<b[j+1]???????????????????????? { double temp ; //????? temp = b[j] ; b[j] = b[j+1] ; b[j+1] = temp ; int tempx ; tempx = biaoji[j][0] ; //?????????? biaoji[j][0] = biaoji[j+1][0] ; biaoji[j+1][0] = tempx ; tempx = biaoji[j][1] ; //?????????? biaoji[j][1] = biaoji[j+1][1] ; biaoji[j+1][1] = tempx ; } } } for( i = 0 ; i < n * ( n - 1 ) / 2 ; i++) //?? cout << "(" << a[biaoji[i][0]][0] << "," << a[biaoji[i][0]][1] << "," << a[biaoji[i][0]][2] << ")-(" << a[biaoji[i][1]][0] << "," << a[biaoji[i][1]][1] << "," << a[biaoji[i][1]][2] << ")=" << fixed << setprecision(2) << b[i] << endl ; return 0; }
64
31,784
int main() { int x[100][30],i,j,k=0,m,n,p; double s[1000],a; scanf("%d",&n); m=n*(n-1)/2; for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&x[i][j]); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ s[k]=sqrt((pow(x[i][0]-x[j][0],2)+pow(x[i][1]-x[j][1],2)+pow(x[i][2]-x[j][2],2))*1.0); k++; } } for(i=1;i<k;i++){ for(j=0;j<k-i;j++){ if(s[j]>s[j+1]){ a=s[j]; s[j]=s[j+1]; s[j+1]=a; } } } for(p=k-1;p>=0;p--){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(s[p]!=s[p+1]){ if(sqrt((pow(x[i][0]-x[j][0],2)+pow(x[i][1]-x[j][1],2)+pow(x[i][2]-x[j][2],2))*1.0)==s[p]) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i][0],x[i][1],x[i][2],x[j][0],x[j][1],x[j][2],s[p]);} } } } } return 0; }
64
31,785
int main() { int n; scanf("%d",&n); int i,j,k; double sz[100],e; struct q{ int x,y,z; }a[100],b[100],c[100],m; for(i=0;i<n;i++) { scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); } int l=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { sz[l]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); b[l]=a[i]; c[l]=a[j]; l++; } } for(k=1;k<=l;k++) { for(i=0;i<l-k;i++) { if(sz[i]<sz[i+1]) { e=sz[i]; sz[i]=sz[i+1]; sz[i+1]=e; m=b[i]; b[i]=b[i+1]; b[i+1]=m; m=c[i]; c[i]=c[i+1]; c[i+1]=m; } } } for(i=0;i<l;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i].x,b[i].y,b[i].z,c[i].x,c[i].y,c[i].z,sz[i]); } return 0; }
64
31,786
int main() { int n,a[11][4],b[60][7],t[7]; double c[60],t0; int i,j,l = 0; 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++) { l++; b[l][1] = a[i][1]; b[l][2] = a[i][2]; b[l][3] = a[i][3]; b[l][4] = a[j][1]; b[l][5] = a[j][2]; b[l][6] = a[j][3]; c[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])); } } for(j = 1;j <= n * (n - 1) / 2 - 1;j++) { for(l = n * (n - 1) / 2 - 1;l >= j;l--) { if(c[l] < c[l + 1]) { for(i = 1;i <= 6;i++) { t[i] = b[l][i]; b[l][i] = b[l + 1][i]; b[l + 1][i] = t[i]; } t0 = c[l]; c[l] = c[l + 1]; c[l + 1] = t0; } } } for(l = 1;l <= n * (n - 1) / 2;l++) { cout << "(" << b[l][1] << "," << b[l][2] << "," << b[l][3] << ")" << "-" << "(" << b[l][4] << "," << b[l][5] << "," << b[l][6] << ")" << "=" << fixed << setprecision(2) << c[l] << endl; } return 0; }
64
31,787
/* * ds.cpp * * Created on: 2011-12-9 * Author: admin */ struct place{ int x; int y; int z; }; struct distance{ int i1; int i2; double dis; }; int main(){ int i,j,k,n; struct place a[11]; struct distance d[100],temp; cin>>n; for (i=1;i<=n;i++){ cin>>a[i].x>>a[i].y>>a[i].z; } k=1; for (i=1;i<=n-1;i++){ for (j=i+1;j<=n;j++){ d[k].i1=i; d[k].i2=j; d[k].dis=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+ (a[i].y-a[j].y)*(a[i].y-a[j].y)+ (a[i].z-a[j].z)*(a[i].z-a[j].z)); k++; } } for (i=k-1;i>=1;i--){ for (j=1;j<=i-1;j++){ if (d[j].dis<d[j+1].dis){ temp=d[j]; d[j]=d[j+1]; d[j+1]=temp; } } } for (i=1;i<=k-1;i++){ cout<<'('<<a[d[i].i1].x<<','<<a[d[i].i1].y<<','<<a[d[i].i1].z<<')'<<'-'<< '('<<a[d[i].i2].x<<','<<a[d[i].i2].y<<','<<a[d[i].i2].z<<')'<<'='<< fixed<<setprecision(2)<<d[i].dis; if (i!=k-1)cout<<endl; } return 0; }
64
31,788
int main(){ int i,j,n,k,l,r; int x[10],y[10],z[10]; double s[100]={0.0},e; scanf("%d\n",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } l=0; for(i=0;i<n-1;i++){ for(k=i+1;k<n;k++){ r=(x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]); s[l]=sqrt(1.0*r); l++; }} for(i=1;i<=l;i++){ for(j=0;j<=l-i;j++){ if(s[j]<s[j+1]){ e=s[j+1]; s[j+1]=s[j]; s[j]=e;}}} for(i=0;i<n*(n-1)/2;i++){ for(j=0;j<n;j++){ for(k=j+1;k<n;k++){ r=(x[j]-x[k])*(x[j]-x[k])+(y[j]-y[k])*(y[j]-y[k])+(z[j]-z[k])*(z[j]-z[k]); if(s[i]!=s[i+1]){ if(s[i]==sqrt(1.0*r)){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[j],y[j],z[j],x[k],y[k],z[k],s[i]);} }else{continue;} }}} return 0; }
64
31,789
//******************************** //*????*********************** //*??? 1300012920************** //******************************** int main() { int n , i , j; int x , y , z; int cnt = 0; //???????"zuobiao"???????? struct { int x; int y; int z; }zuobiao[10]; struct { int x1; int y1; int z1; int x2; int y2; int z2; int num1; int num2; double len; }len[50]; cin >> n;//?????? for(i = 0 ; i < n ; i++)//?????? { cin >> x >> y >> z; zuobiao[i].x = x; zuobiao[i].y = y; zuobiao[i].z = z; } //???????????????????????len? for(i = 0 ; i < n - 1 ; i++) for(j = i + 1 ; j < n ; j++) { len[cnt].x1 = zuobiao[i].x; len[cnt].y1 = zuobiao[i].y; len[cnt].z1 = zuobiao[i].z; len[cnt].x2 = zuobiao[j].x; len[cnt].y2 = zuobiao[j].y; len[cnt].z2 = zuobiao[j].z; len[cnt].num1 = i; len[cnt].num2 = j; len[cnt].len = sqrt((zuobiao[i].x - zuobiao[j].x) * (zuobiao[i].x - zuobiao[j].x) + (zuobiao[i].y - zuobiao[j].y) * (zuobiao[i].y - zuobiao[j].y) + (zuobiao[i].z - zuobiao[j].z) * (zuobiao[i].z - zuobiao[j].z)); cnt++; } for(i = 0 ; i < (n - 1) * n / 2 - 1 ; i++) for(j = i + 1 ; j < (n - 1) * n / 2 ; j++) { //????????????len[]???? if(len[i].len < len[j].len) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } //??????????????? if(len[i].len == len[j].len && len[i].num1 > len[j].num1) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } //???????????????????????? if(len[i].len == len[j].len && len[i].num1 == len[j].num1 && len[i].num2 > len[j].num2) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } } cout << fixed; for(j = 0 ; j < n * (n - 1) / 2 ; j++) cout << "(" << len[j].x1 << "," << len[j].y1 << "," << len[j].z1 << ")-(" << len[j].x2 << "," << len[j].y2 << "," << len[j].z2 <<")=" << setprecision(2) << len[j].len << endl; return 0; }
64
31,790
struct point { int x; int y; int z; }; double dis(struct point b,struct point c); int main() { int n,a,i=0,j=0,k; struct point str[10]; struct thr{ float d; int e; int f; }; struct thr temp={0}; struct thr str1[10000]={0}; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&str[i].x,&str[i].y,&str[i].z); i=0; for(j=0;j<n-1;j++) { k=j+1; for(k=j+1;k<n;k++) { str1[i].d=dis(str[j],str[k]); str1[i].e=j; str1[i].f=k; i++; } } a=i; j=0; k=0; for(j=0;j<a-1;j++) { k=0; for(k=0;k<a-j;k++) { if(str1[k].d<str1[k+1].d) {temp=str1[k]; str1[k]=str1[k+1]; str1[k+1]=temp; } } } i=0; for(i=0;i<a;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",str[str1[i].e].x,str[str1[i].e].y,str[str1[i].e].z,str[str1[i].f].x, str[str1[i].f].y,str[str1[i].f].z,str1[i].d); printf("\n"); } return 0; } double dis(struct point b,struct point c) { return sqrt(pow((b.x-c.x),2)+pow((b.y-c.y),2)+pow((b.z-c.z),2)); }
64
31,791
int main() { int n,i,j,m=0,k,s,t; cin >> n; double d[101][101]; struct point { int x; int y; int z; }p[11]; for (i=0;i<=n-1;i++) { cin >> p[i].x >> p[i].y >> p[i].z; } for (i=0;i<n;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)); } } for (t=0;t<(n*(n+1))/2;t++) { for (i=0;i<n;i++) { for (j=i+1;j<n;j++) { m=0; for (k=0;k<n;k++) { for (s=k+1;s<=n;s++) { if (d[i][j]<d[k][s]) m++; } } if (m==t) { cout<< "(" << p[i].x << "," << p[i].y << "," << p[i].z << ")"<< "-" <<"(" << p[j].x << "," << p[j].y << "," << p[j].z << ")"<< "=" << fixed << setprecision (2) << d[i][j] << endl; } } } } return 0; }
64
31,792
int main() { int n,j,t,a,b,r=0,x[10],y[10],z[10]; double e,sz[45][3]; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(j=0;j<n-1;j++){ for(t=j+1;t<n;t++){ sz[r][0]=j; sz[r][1]=t; sz[r][2]=sqrt((x[j]-x[t])*(x[j]-x[t])+(y[j]-y[t])*(y[j]-y[t])+(z[j]-z[t])*(z[j]-z[t])); r++; } } for(j=1;j<=r;j++){ for(t=0;t<r-j;t++){ if(sz[t][2]<sz[t+1][2]){ e=sz[t][2]; sz[t][2]=sz[t+1][2]; sz[t+1][2]=e; e=sz[t][0]; sz[t][0]=sz[t+1][0]; sz[t+1][0]=e; e=sz[t][1]; sz[t][1]=sz[t+1][1]; sz[t+1][1]=e; } } } for(j=0;j<r;j++){ int a=sz[j][0]; int b=sz[j][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a],y[a],z[a],x[b],y[b],z[b],sz[j][2]); } return 0; }
64
31,793
int main() { int a[1000][3],n,m,l=1,i,j; double b[3000][3],q,w,e; scanf("%d",&n); m=n*(n-1)/2; for( i=1;i<=n;i++){ for(j=1;j<=3;j++){ scanf("%d",&a[i][j]); }} for(i=1;i<=n;i++){ for( j=i+1;j<=n;j++){ b[l][1]=i; b[l][2]=j; b[l][3]=sqrt((double)( (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]) ) ); l++;} } for(i=1;i<=m;i++){ for( j=1;j<=m-i;j++){ if(b[j][3]<b[j+1][3]){ q=b[j][1]; w=b[j][2]; e=b[j][3]; b[j][1]=b[j+1][1];b[j][2]=b[j+1][2];b[j][3]=b[j+1][3]; b[j+1][1]=q; b[j+1][2]=w; b[j+1][3]=e; } } } for(i=1;i<=m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", a[(int)b[i][1]][1],a[(int)b[i][1]][2],a[(int)b[i][1]][3], a[(int)b[i][2]][1],a[(int)b[i][2]][2],a[(int)b[i][2]][3], b[i][3]); } return 0; }
64
31,794
void main() {int i,j,k=1,n,sa[100][3],b=0; double s[100]={0},point[10][3],a,c; scanf("%d",&n); for (i=0;i<n;i++) {scanf("%lf%lf%lf", &point[i][0],&point[i][1],&point[i][2]);} for (i=0;i<n-1;i++) {for (j=i+1;j<n;j++,k++) {c=(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]); s[k]=sqrt(c); sa[k][1]=i; sa[k][2]=j; } } for (i=1;i<k;i++) {for (j=k-1;j>1;j--) if (s[j]>s[j-1]+0.000001) {s[j-1]=s[j]+s[j-1]; s[j]=s[j-1]-s[j]; s[j-1]=s[j-1]-s[j]; b=sa[j][1]; sa[j][1]=sa[j-1][1]; sa[j-1][1]=b; b=sa[j][2]; sa[j][2]=sa[j-1][2]; sa[j-1][2]=b; } } for (i=1;i<k;i++) {b=sa[i][1]; printf("(%.0lf,%.0lf,%.0lf)-",point[b][0],point[b][1],point[b][2]); b=sa[i][2]; printf("(%.0lf,%.0lf,%.0lf)=",point[b][0],point[b][1],point[b][2]); printf("%.2lf\n", s[i]);} }
64
31,795
double cal(int a[3],int b[3]) { int i=0,sum=0; for(;i<3;i++) sum+=(a[i]-b[i])*(a[i]-b[i]); return sqrt(sum); } int change(double a[7],double b[7]) { double temp; int i; for(i=0;i<7;i++) { temp=a[i]; a[i]=b[i]; b[i]=temp; } return 0; } void main() { int i,j,n,a[10][3],k1=0,k2; double b[60][7]; 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-1;i++) for(j=i+1;j<n;j++) { for(k2=0;k2<3;k2++) b[k1][k2]=a[i][k2]; for(k2=0;k2<3;k2++) b[k1][k2+3]=a[j][k2]; b[k1][6]=cal(a[i],a[j]); k1++; } for(i=0;i<k1;i++) for(j=0;j<k1-1;j++) if(b[j][6]<b[j+1][6]) change(b[j],b[j+1]); for(i=0;i<k1;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,796
//****************************************************** //* ? ? ? ?? ? ? ? * //* ? ? ?? ? ? * //* ? ? ? ??2010 ? 12 ? 15 ? * //* ? ? ?1000010185 * //****************************************************** int main() { struct distance // ??????????????? { int x[3]; int y[3]; double d; } dis[45], temp; int n, a[10][3]; // ??a???n???? cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) cin >> a[i][j]; // ?n?????????????dis? int k = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) { for (int p = 0; p < 3; p++) { dis[k].x[p] = a[i][p]; dis[k].y[p] = a[j][p]; } k++; } // ?????????? int k1 = n * (n - 1) / 2; for (int i = 0; i < k1; i++) { double sum = 0; for (int j = 0; j < 3; j++) sum += (dis[i].x[j] - dis[i].y[j]) * (dis[i].x[j] - dis[i].y[j]); dis[i].d = sqrt(sum); for (int j = i - 1; j >= 0; j--) if (dis[j + 1].d > dis[j].d) { temp = dis[j]; dis[j] = dis[j + 1]; dis[j + 1] = temp; } } // ??????????? for (int i = 0; i < k1; i++) cout << '(' << dis[i].x[0] << ',' << dis[i].x[1] << ',' << dis[i].x[2] << ")-(" << dis[i].y[0] << ',' << dis[i].y[1] << ',' << dis[i].y[2] << ")=" << fixed << setprecision(2) << dis[i].d << endl; return 0; }
64
31,797
int main() { int n,x[20],y[20],z[20]={0},ju[200],xx[200],yy[200],zz[200]={0},xxx[200],yyy[200],zzz[200]={0}; int i,j,k=0,m; double l[200]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { ju[k]=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); l[k]=sqrt(ju[k]); xx[k]=x[i];xxx[k]=x[j];yy[k]=y[i];yyy[k]=y[j];zz[k]=z[i];zzz[k]=z[j]; k++; } } for(i=0;i<k;i++) { for(j=0;j<k-1;j++) { if(l[j]<l[j+1]) { double t=l[j+1];l[j+1]=l[j];l[j]=t; m=xx[j+1];xx[j+1]=xx[j];xx[j]=m; m=yy[j+1];yy[j+1]=yy[j];yy[j]=m; m=zz[j+1];zz[j+1]=zz[j];zz[j]=m; m=xxx[j+1];xxx[j+1]=xxx[j];xxx[j]=m; m=yyy[j+1];yyy[j+1]=yyy[j];yyy[j]=m; m=zzz[j+1];zzz[j+1]=zzz[j];zzz[j]=m; } else continue; } } for(i=0;i<k;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", xx[i], yy[i], zz[i], xxx[i], yyy[i], zzz[i], l[i]); } return 0; }
64
31,798
int main(){ int n,m,j,e,x[101],y[101],z[101],a[20000],b[20000]; int s[10000]; int t=0; double c[10000]; scanf("%d\n",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]);} for(int i=0;i<n;i++){ for(j=i+1;j<n;j++){ s[t]=(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[t]=i;b[t]=j;t++; }} for(int i=0;i<t-1;i++){ for(j=0;j<t-i-1;j++){ if(s[j]<s[j+1]){ e=s[j+1]; s[j+1]=s[j]; s[j]=e; e=a[j+1];a[j+1]=a[j];a[j]=e;e=b[j+1];b[j+1]=b[j];b[j]=e; } }} for(m=0;m<t;m++){ c[m]=1.0*sqrt(s[m]);} for(m=0;m<t;m++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a[m]],y[a[m]],z[a[m]],x[b[m]],y[b[m]],z[b[m]],c[m]);} return 0; }
64
31,799
struct dian{ float x; float y; float z; }; struct diandui{ struct dian a; struct dian b; float dis; }; void main(){ int n,i,j,t=0; struct dian d[10]; struct diandui dui[50],temp; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%f%f%f",&d[i].x,&d[i].y,&d[i].z); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ dui[t].a=d[i]; dui[t].b=d[j]; //printf("%f %f",d[i].x,d[j].x); dui[t].dis=sqrt((d[i].x-d[j].x)*(d[i].x-d[j].x)+(d[i].y-d[j].y)*(d[i].y-d[j].y)+(d[i].z-d[j].z)*(d[i].z-d[j].z)); //printf("%.2f\n",dui[t].dis); t++; } } for(i=0;i<t;i++){ for(j=0;j<t-1-i;j++){ if(dui[j].dis<dui[j+1].dis){ temp=dui[j]; dui[j]=dui[j+1]; dui[j+1]=temp; } } } for(i=0;i<t;i++){ printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",dui[i].a.x,dui[i].a.y,dui[i].a.z,dui[i].b.x,dui[i].b.y,dui[i].b.z,dui[i].dis); } }
64