label
stringlengths
1
2
index
stringlengths
1
5
code
stringlengths
87
8.24k
64
31900
//******************************** //*??????? ** //*?????? 1300012713 ** //*???2013.12.14 ** //******************************** int main() { int n, b = 0,a[15][3]; struct distance { double ds; int a1; int a2; }d[50]; cin >> n; for(int i = 1; i <= n; i++) cin >> a[i][0] >> a[i][1] >> a[i][2]; for(int j = 1; j <= n; j++) { for(int k = j + 1; k <= n; k++) { b++; d[b].ds = 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])); d[b].a1 = j; d[b].a2 = k; } } for(int p = 1; p <= b; p++) { for(int q = 1; q <= b-p+1; q++) { if(d[q].ds < d[q+1].ds) { double b0 = d[q].ds; int b1 = d[q].a1; int b2 = d[q].a2; d[q].ds = d[q+1].ds; d[q].a1 = d[q+1].a1; d[q].a2 = d[q+1].a2; d[q+1].ds = b0; d[q+1].a1 = b1; d[q+1].a2 = b2; } } } for(int l = 1; l <= b; l++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[d[l].a1][0],a[d[l].a1][1],a[d[l].a1][2],a[d[l].a2][0],a[d[l].a2][1],a[d[l].a2][2],d[l].ds); return 0; }
64
31901
int read(); void calculate(); void sort(); double sqr(double p); int print(); int x[100],y[100],z[100],n; double a[100][100]; int main() { read(); calculate(); print(); return 0; } int read() { int i; scanf("%d",&n); for (i=1;i<=n;i++) scanf ("%d%d%d",&x[i],&y[i],&z[i]); return 0; } void calculate() { int i,j; for (i=1;i<n;i++) for (j=i+1;j<=n;j++) a[i][j]=sqr((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); return; } int print() { int i,j,k,l,p; double max; p=n*(n-1)/2; while (p>0) { max=-1; for (i=1;i<n;i++) for(j=n;j>i;j--) { if (max<a[i][j]) { max=a[i][j]; k=i; l=j; } else if (max==a[i][j]) { if (k>i) { k=i; l=j; } else if (k==i&&l>j) { l=j; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[k],y[k],z[k],x[l],y[l],z[l],a[k][l]); a[k][l]=-100; p--; } return 0; } double sqr(double p) { double x1,x2; x2=p; x1=1.0; while (fabs(x2-x1)>1e-10) { x1=x2; x2=(x1+p/x1)/2; } return x2; }
64
31902
struct A { int x1,y1,z1; }a[10]; double juli(int a,int b,int c,int d,int e,int f) { double m; m=(double)(a-d)*(a-d)+(b-e)*(b-e)+(c-f)*(c-f); m=sqrt(m); return m; } int cmp(const void * a, const void * b) { return((*(double*)a-*(double*)b>0)?1:-1); } int main() { int n,i,j,k,l=0,flag; double b[50]; while(cin>>n&&n)//?????? { k=0; for(i=0;i<n;i++)//??? { cin>>a[i].x1; cin>>a[i].y1; cin>>a[i].z1; } for(i=0;i<n;i++)//??? for(j=i+1;j<n;j++) b[k++]=juli(a[i].x1,a[i].y1,a[i].z1,a[j].x1,a[j].y1,a[j].z1);//???b[i]?? qsort(b,n*(n-1)/2,sizeof(b[0]),cmp);//???? l=n*(n-1)/2-1; flag=0; while(l>=0) { for(i=0;i<n;i++) { for(j=i+1;j<n;j++) if( b[l]==juli(a[i].x1,a[i].y1,a[i].z1,a[j].x1,a[j].y1,a[j].z1)) { // printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i].x1,a[i].y1,a[i].z1,a[j].x1,a[j].y1,a[j].z1,b[l]); cout<<"("<<a[i].x1<<","<<a[i].y1<<","<<a[i].z1<<")"<<"-"<<"("<<a[j].x1<<","<<a[j].y1<<","<<a[j].z1<<")"<<"="<<fixed<<setprecision(2)<<b[l]<<endl; l--; if(b[l]==b[l+1]) continue; else { flag=1; break; } } if(flag==1) { flag=0; break; } } } } return 0; }
64
31903
int main() { int i,n,j=1,x[11],y[11],z[11],a,b,k; double d[50],t; cin>>n; for(i=1;i<=n;i++) cin>>x[i]>>y[i]>>z[i]; for(i=1;i<n;i++) for(k=i+1;k<=n;k++) { d[j]=sqrt(pow(x[i]-x[k],2.0)+pow(y[i]-y[k],2.0)+pow(z[i]-z[k],2.0)); j++; } for(j=1;j<=(n*(n-1)/2-1);j++) for(i=1;i<=(n*(n-1)/2-j);i++) if (d[i]<d[i+1]) {t=d[i];d[i]=d[i+1];d[i+1]=t;} for(i=1;i<=(n*(n-1)/2);i++) { if(d[i]==d[i+1]) continue; for(a=1;a<n;a++) for(b=a+1;b<=n;b++) if(sqrt(pow(x[a]-x[b],2.0)+pow(y[a]-y[b],2.0)+pow(z[a]-z[b],2.0))==d[i]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[a],y[a],z[a],x[b],y[b],z[b],d[i]); } return 0; }
64
31904
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
31905
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
31906
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
31907
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
31908
/** * @file C12Q4.cpp * @author ??? * @date 2013-12-14 * @description * ??????:???? */ typedef struct node { int x,y,z; }node; typedef struct distance { node*pn1,*pn2; double v; }dis; int main() { int n; node ns[MAX]; dis ds[MAX*MAX]; cin >> n; for(int i = 0 ; i < n ; i++) { cin >> ns[i].x >> ns[i].y >> ns[i].z; } int p = 0 ; for(int i = 0 ; i < n ; i++) for(int j = i+1 ; j < n ; j++) { ds[p].pn1 = ns+i; ds[p].pn2 = ns+j; ds[p].v = sqrt((ns[i].x - ns[j].x)*(ns[i].x - ns[j].x)+(ns[i].y - ns[j].y)*(ns[i].y - ns[j].y) +(ns[i].z - ns[j].z)*(ns[i].z - ns[j].z)); p++; } for(int i = 0 ; i < p ; i++) { for(int j = p-1; j > i ; j--) { if (ds[j].v > ds[j-1].v) { dis tmp = ds[j]; ds[j] = ds[j-1]; ds[j-1] = tmp; } } } for(int i = 0 ; i < p ; i ++) { cout << '(' <<ds[i].pn1 ->x << ',' << ds[i].pn1 ->y << ',' << ds[i].pn1 ->z << ')' << '-' ; cout << '(' <<ds[i].pn2 ->x << ',' << ds[i].pn2 ->y << ',' << ds[i].pn2 ->z << ')' << '=' ; cout << setprecision(2) << fixed <<ds[i].v << endl; } return 0; }
64
31909
int main () {int n; scanf ("%d",&n); struct dot { int x,y,z; double len[9]; } dots[10]; for (int i1=0;i1<n;i1++) { scanf("%d%d%d",&dots[i1].x,&dots[i1].y,&dots[i1].z); } for (int i2=0;i2<n-1;i2++) { for (int i3=n-i2-2;i3>=0;i3--) { dots[i2].len[n-i2-2-i3]=(dots[i2].x-dots[n-i3-1].x)*(dots[i2].x-dots[n-i3-1].x)+(dots[i2].y-dots[n-i3-1].y)*(dots[i2].y-dots[n-i3-1].y)+(dots[i2].z-dots[n-i3-1].z)*(dots[i2].z-dots[n-i3-1].z); dots[i2].len[n-i2-2-i3]=sqrt(dots[i2].len[n-i2-2-i3]); } } for (int j=0;j<n*(n-1)/2;j++) {int maxq=0,maxh=0; double lmax=0.0; for (int i4=0;i4<n-1;i4++) { for (int i5=0;i5<=n-2-i4;i5++) { if (dots[i4].len[i5]>lmax){lmax=dots[i4].len[i5];maxq=i4;maxh=i4+i5+1;} } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dots[maxq].x,dots[maxq].y,dots[maxq].z,dots[maxh].x,dots[maxh].y,dots[maxh].z,dots[maxq].len[maxh-1-maxq]); dots[maxq].len[maxh-1-maxq]=0; } return 0; }
64
31910
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
31911
int main(){ int a[10][3],m,i,j,n,d[45][6],w; double b[45],q; m=0; 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[m]=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])); d[m][0]=a[i][0]; d[m][1]=a[i][1]; d[m][2]=a[i][2]; d[m][3]=a[j][0]; d[m][4]=a[j][1]; d[m][5]=a[j][2]; m++; } } for(i=0;i<m;i++){ for(j=0;j<m-i-1;j++){ if(b[j]<b[j+1]){ q=b[j]; b[j]=b[j+1]; b[j+1]=q; w=d[j][0]; d[j][0]=d[j+1][0]; d[j+1][0]=w; w=d[j][1]; d[j][1]=d[j+1][1]; d[j+1][1]=w; w=d[j][2]; d[j][2]=d[j+1][2]; d[j+1][2]=w; w=d[j][3]; d[j][3]=d[j+1][3]; d[j+1][3]=w; w=d[j][4]; d[j][4]=d[j+1][4]; d[j+1][4]=w; w=d[j][5]; d[j][5]=d[j+1][5]; d[j+1][5]=w; }}} for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",d[i][0],d[i][1],d[i][2],d[i][3],d[i][4],d[i][5],b[i]); } return 0; }
64
31912
struct d { int q[2]; //q ???????? float dis; }; int main() { int n,i,j,k=0,t2[2]; struct d dist[100]; float a[10][3],t1; //?????????a? scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<3;j++) scanf("%f",&a[i][j]); for(i=0;i<n;i++) for(j=i+1;j<n;j++) { dist[k].dis=sqrtf( (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]) );//???? dist[k].q[0]=i; dist[k].q[1]=j; k++; } for(i=0;i<n*(n-1)/2;i++) //?????????????????? for(j=n*(n-1)/2-1;j>0;j--) { if(dist[j-1].dis<dist[j].dis) { t1=dist[j-1].dis; t2[0]=dist[j-1].q[0]; t2[1]=dist[j-1].q[1]; dist[j-1].dis=dist[j].dis; dist[j-1].q[0]=dist[j].q[0]; dist[j-1].q[1]=dist[j].q[1]; dist[j].dis=t1; dist[j].q[0]=t2[0]; dist[j].q[1]=t2[1]; } } for(i=0;i<n*(n-1)/2;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",(int)a[dist[i].q[0]][0],(int)a[dist[i].q[0]][1],(int)a[dist[i].q[0]][2],(int)a[dist[i].q[1]][0],(int)a[dist[i].q[1]][1],(int)a[dist[i].q[1]][2],dist[i].dis); return 0; }
64
31913
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
31914
int p[100][3]; //????????n????? struct Distance { int p1,p2; //????p1?p2??? double d; }; int main() { int n; cin>>n; int i,j,k; for(i=0;i<n;i++) for(j=0;j<3;j++) cin>>p[i][j]; struct Distance a[100*100+10],temp; int m=0; //????m for(i=0;i<n;i++) for(j=i+1;j<n;j++) { double sum=0; for(k=0;k<3;k++) sum+=pow(p[i][k]*1.0-p[j][k]*1.0,2*1.0); a[m].d=sqrt(sum); a[m].p1=i; //????????????Distance a[m] a[m].p2=j; m++; } for(i=0;i<m;i++) //???? for(j=0;j<m-i;j++) if(a[j].d<a[j+1].d) { temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } for(i=0;i<m;i++) { cout<<"("<<p[a[i].p1][0]<<","<<p[a[i].p1][1]<<","<<p[a[i].p1][2]<<")"<<"-" <<"("<<p[a[i].p2][0]<<","<<p[a[i].p2][1]<<","<<p[a[i].p2][2]<<")"<<"=" <<fixed<<setprecision(2)<<a[i].d<<endl; } return 0; }
64
31915
int main() { struct point { int x; int y; int z; }p[10]; struct distance { int x1,x2; int y1,y2; int z1,z2; double d; }d[46],t; int n,i,j,k=0,m; 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].x1=p[i].x; d[k].x2=p[j].x; d[k].y1=p[i].y; d[k].y2=p[j].y; d[k].z1=p[i].z; d[k].z2=p[j].z; d[k].d=sqrt(((double)d[k].x1-(double)d[k].x2)*((double)d[k].x1-(double)d[k].x2)+((double)d[k].y1-(double)d[k].y2)*((double)d[k].y1-(double)d[k].y2)+((double)d[k].z1-(double)d[k].z2)*((double)d[k].z1-(double)d[k].z2)); k++; } m=k; struct distance *pointer1,*pointer2; pointer1=d; pointer2=&t; for(i=0;i<m-1;i++) for(j=m-1;j>i;j--) { if((pointer1+j)->d>(pointer1+j-1)->d) { *pointer2=*(pointer1+j); *(pointer1+j)=*(pointer1+j-1); *(pointer1+j-1)=*pointer2; } } for(k=0;k<m;k++) { cout<<"("<<d[k].x1<<","<<d[k].y1<<","<<d[k].z1<<")"<<"-"<<"("<<d[k].x2<<","<<d[k].y2<<","<<d[k].z2<<")"<<"=" <<fixed<<setprecision(2)<<d[k].d<<endl; } return 0; }
64
31916
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
31917
int main() { int n,a[10][3],i,j,k; double b[10][10]; cin>>n; for(i=0;i<=n-1;i++) for(j=0;j<=2;j++) cin>>a[i][j]; for(i=0;i<=n-1;i++) for(j=i+1;j<=n-1;j++) b[i][j]=sqrt(pow((double)(a[i][0]-a[j][0]),2)+pow((double)(a[i][1]-a[j][1]),2)+pow((double)(a[i][2]-a[j][2]),2)); for(k=1;k<=n*(n-1)/2;k++) { double r=-1; int first,next; for(i=0;i<=n-1;i++) for(j=i+1;j<=n-1;j++){ if(b[i][j]>r){ r=b[i][j]; first = i; next = j; } } cout<<"("<<a[first][0]<<","<<a[first][1]<<","<<a[first][2]<<")-(" <<a[next][0]<<","<<a[next][1]<<","<<a[next][2]<<")=" <<fixed<<setprecision(2)<<r<<endl; b[first][next] = -9999999; } cin>>n; return 0; }
64
31918
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
31919
//****************************************** //*???????.cpp ** //*??: ?? 1100012808 ** //*???2011.12.07 ** //****************************************** double d[45]; int n; void maopaopaixu(double d[]) { int i, j; double t; for (i = 0; i < n * (n - 1) / 2; i++) { for (j = 0; j < n * (n - 1) / 2 - i; j++) { if (d[j] < d[j + 1]) { t = d[j]; d[j] = d[j + 1]; d[j + 1] = t; } } } } int main() //??? { //????? int i, j, k = 0, flag, a[11][3] = {0}, g[10][10] = {0}; double b[10][10] = {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++) { d[k] = sqrt((a[i][1] - a[j][1]) * (a[i][1] - a[j][1]) + (a[i][0] - a[j][0]) *(a[i][0] - a[j][0]) + (a[i][2] - a[j][2]) * (a[i][2] - a[j][2])); b[i][j] = d[k]; k++; } } maopaopaixu(d); for (k = 0; k < n * (n - 1) / 2; k++) { flag = 0; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) { if (fabs(b[i][j] - d[k]) < 0.00000001 && g[i][j] == 0) { cout << "(" << a[i][0] << "," << a[i][1] << "," << a[i][2] << ")" << "-" << "(" << a[j][0] << "," << a[j][1] << "," << a[j][2] << ")" << "=" << fixed << setprecision(2) << d[k] << endl; flag = 1; g[i][j] = 1; break; } } if (flag) break; } } return 0; } //?????
64
31920
int main(){ int n,a,l=0,c,d; scanf("%d",&n); a=n*(n-1)/2; int x[n],y[n],z[n],q[a],p[a]; double s[a],b; 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++){ 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])); p[l]=i; q[l]=k; l++; } } for(int i=1;i<=a;i++){ for(int k=0;k<a-i;k++){ if(s[k]<s[k+1]){ b=s[k]; s[k]=s[k+1]; s[k+1]=b; c=p[k]; p[k]=p[k+1]; p[k+1]=c; d=q[k]; q[k]=q[k+1]; q[k+1]=d; } } } for(int i=0;i<a;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p[i]],y[p[i]],z[p[i]],x[q[i]],y[q[i]],z[q[i]],s[i]); } return 0; }
64
31921
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
31922
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; } 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; }
64
31923
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
31924
int main(){ int n,a[30],b[45],c[45],p=0,e,q,g,i,t,k,s,x,h,j,v; double dis[45],mid; scanf("%d",&n); for(i=0;i<(3*n);i++){ scanf("%d",&a[i]); } for(t=0;t<n;t++){ for(k=t+1;k<n;k++){ b[p]=t;c[p]=k; e=(a[3*t]-a[3*k])*(a[3*t]-a[3*k])+(a[3*t+1]-a[3*k+1])*(a[3*t+1]-a[3*k+1])+(a[3*t+2]-a[3*k+2])*(a[3*t+2]-a[3*k+2]); dis[p]=sqrt(e); p++; } } for(s=1;s<=p;s++){ for(x=0;x<p-s;x++){ if(dis[x]<dis[x+1]){ mid=dis[x+1]; dis[x+1]=dis[x]; dis[x]=mid; q=b[x+1]; b[x+1]=b[x]; b[x]=q; g=c[x+1]; c[x+1]=c[x]; c[x]=g; } } } for(h=0;h<p;h++){ j=3*b[h];v=3*c[h]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[j],a[j+1],a[j+2],a[v],a[v+1],a[v+2],dis[h]); } return 0; }
64
31925
int main() { int n,i,j,k;//?????? int x[10],y[10],z[10];//????????? float d[90]={0},temp=0;//?????????0 cin>>n; for(i=0;i<=n-1;++i) cin>>x[i]>>y[i]>>z[i];//???? for(i=0;i<=n-2;++i) { for(j=i+1;j<=n-1;++j) { d[10*i+j]=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(j=1;j<=(n-1)*n/2;++j)//???? ?????? { for(i=1;i<=89;++i) { if(d[i]==0) continue;//???0 ?????? continue if(d[i]>temp) { temp=d[i];//???? k=i; } } cout<<"("<<x[k/10]<<","<<y[k/10]<<","<<z[k/10]<<")"<<"-"<<"("<<x[k%10]<<","<<y[k%10]<<","<<z[k%10]<<")"<<"="<<fixed<<setprecision(2)<<temp<<endl;//?? d[k]=0;//???0 temp=0;//???0 k=0;//???0 ?????? } return 0; }
64
31926
int main(){ int i,j,k,m,n,a,b; int sz[200] [4]; scanf("%d",&n); double r[200][200],o[100000],e; for(i=0;i<n;i++){ scanf("%d %d %d",&sz[i] [1],&sz[i] [2],&sz[i] [3]); } for(i=0;i<n;i++){ for(j=0;j<n;j++){ r[i][j]=sqrt((double)(((sz[i][1])-(sz[j][1]))*((sz[i][1])-(sz[j][1]))+((sz[i][2])-(sz[j][2]))*((sz[i][2])-(sz[j][2]))+((sz[i][3])-(sz[j][3]))*((sz[i] [3])-(sz[j][3])))); } } for(i=0;i<n;i++){ for(j=0;j<n;j++){ o[(i)*n+j]=r[i][j]; } } for(i=1;i<=n*n;i++){ for(j=1;j<n*n;j++){ if(o[j]<o[j+1]){ e=o[j]; o[j]=o[j+1]; o[j+1]=e; } } } //for(i=1;i<=n*n;i++)cout<<o[i]; for(i=0;i<n*n;i++){ if(o[i]==o[i-1]) continue; for(j=0;j<n;j++){ for(b=j+1;b<n;b++){ if(o[i+1]==r[j][b]){printf("(%d,%d,%d)",sz[j][1],sz[j][2],sz[j][3]);printf("%c",'-'); printf("(%d,%d,%d)",sz[b][1],sz[b][2],sz[b][3]);printf("%c",'='); printf("%.2lf",r[b][j]);cout<<endl; } } } } return 0; }
64
31927
int main() { int n,i,j,d=1,t,x[12],y[12],z[12]; float g; struct juli { int a; int b; float jl; }l[100]; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { l[d].jl=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]))*1.0); l[d].a=i; l[d].b=j; d++; } } d--; for(i=1;i<=d-1;i++) { for(j=1;j<=d-i;j++) { if (l[j].jl<l[j+1].jl) { g=l[j].jl; l[j].jl=l[j+1].jl; l[j+1].jl=g; t=l[j].a; l[j].a=l[j+1].a; l[j+1].a=t; t=l[j].b; l[j].b=l[j+1].b; l[j+1].b=t; } } } for(i=1;i<=d;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[l[i].a],y[l[i].a],z[l[i].a],x[l[i].b],y[l[i].b],z[l[i].b],l[i].jl); } return 0; }
64
31928
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
31929
int main(){ int n,m,i,j,r; int a[10],b[10],c[10],f[100],g[100],h[100],x[100],y[100],z[100]; double d[100]; scanf("%d",&n); m=0; for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]);} for(i=n-2;i>=0;i--){ for(j=n-1;j>i;j--){ d[m]=(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[m]=sqrt(d[m]); f[m]=a[i]; g[m]=b[i]; h[m]=c[i]; x[m]=a[j]; y[m]=b[j]; z[m]=c[j]; m=m+1;}} for(j=m-1;j>0;j--){ for(r=0;r<j;r++){ if(d[r]>d[r+1]){ double tmp; int t1,t2,t3,t4,t5,t6; tmp=d[r+1]; t1=f[r+1]; t2=g[r+1]; t3=h[r+1]; t4=x[r+1]; t5=y[r+1]; t6=z[r+1]; d[r+1]=d[r]; f[r+1]=f[r]; g[r+1]=g[r]; h[r+1]=h[r]; x[r+1]=x[r]; y[r+1]=y[r]; z[r+1]=z[r]; d[r]=tmp; f[r]=t1; g[r]=t2; h[r]=t3; x[r]=t4; y[r]=t5; z[r]=t6; } } } for(i=m-1;i>=0;i--){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",f[i],g[i],h[i],x[i],y[i],z[i],d[i]); } return 0; }
64
31930
//************************ //*??????? ** //*?????? ** //*???1200012957 ** //*???2012-12-13 ** //************************ struct point // ??????????????? { int x; int y; int z; } p[10]; // ????? struct distance // ??????????????????????????????? { int f; int b; double s; } a[45]; 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 ; } int m = n * (n - 1) / 2; // ????????????? for (i = 0; i < n - 1; i++ ) { for ( j = i + 1; j < n; j++ ) { // ????????? a[k].s = 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)); a[k].f = i; // ????????????? a[k].b = j; k++ ; } } for (i = 0; i < m; i++ ) { k = i; for (j = i + 1; j < m; j++ ) { // ?????????? if (a[k].s < a[j].s) { k = j; } else { // ????????????????? if (a[k].s == a[j].s) { // ?????????????????????? if ((a[k].f > a[j].f) || ((a[k].f == a[j].f) && (a[k].b > a[j].b))) { k = j; } } } } // ?????? cout << "(" << p[a[k].f].x << "," << p[a[k].f].y << "," << p[a[k].f].z << ")-"; cout << "(" << p[a[k].b].x << "," << p[a[k].b].y << "," << p[a[k].b].z << ")="; cout << setprecision(2) << fixed << a[k].s << endl; a[k] = a[i]; } return 0; }
64
31931
/* * julipaixu.cpp *????????n??????10??,??n?????????,???? [ ????] ??????????????????? * Created on: 2013-11-1 * Author: 13141 * ????????????????n??????????????????(??????)?????????0?100???????????????? * ?????n????????n*(n-1)/2??????????? (x1,y1,z1)-(x2,y2,z2)=?? ???????????2?? */ int main() { int n; cin>>n; int x[n],y[n],z[n]; int t=n*(n-1)/2;//CN2 ?? int d[t]; int a[t],b[t];//?????????????? int k=0,i,j; for(i=0;i<n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d[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]));//???????? a[k]=i; b[k]=j; k++; } } for(int c=1;c<t;c++) { for(int r=0;r<(k-c);r++) { if(d[r]<d[r+1]) { swap(d[r],d[r+1]); swap(a[r],a[r+1]); swap(b[r],b[r+1]); } } } for(int w=0;w<t;w++) { cout<<"("<<x[a[w]]<<","<<y[a[w]]<<","<<z[a[w]]<<")-("<<x[b[w]]<<","<<y[b[w]]<<","<<z[b[w]]<<")="<<fixed<<setprecision(2)<<sqrt(d[w])<<endl; } return 0; }
64
31932
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
31933
//Pat.X int main() { int n; //???? int i,j,k,p; //?????? int x,y,z; //????? int m; //???????? scanf("%d",&n); m=n*(n-1)/2; //???????? double c[m],t,t0; //?????????????????? int a[n][3]; //????????? double b[n][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++) { x=a[i][0]-a[j][0]; y=a[i][1]-a[j][1]; z=a[i][2]-a[j][2]; b[i][j]=sqrt(x*x+y*y+z*z); c[k]=b[i][j]; k++; } } for(i=k-1;i>0;i--) //???? { for(j=0;j<i;j++) { if(c[j]<c[j+1]) { t=c[j]; c[j]=c[j+1]; c[j+1]=t; } } } t0=c[0]+1; //???? for(i=0;i<k;i++) //?????? { if(c[i]==t0) continue; if(c[i]!=t0){ //???????????????????? t0=c[i]; for(j=0;j<n-1;j++) { for(p=j+1;p<n;p++) { if(b[j][p]==c[i]) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[j][0],a[j][1],a[j][2],a[p][0],a[p][1],a[p][2],b[j][p]); } } } } } return 0; }
64
31934
int main() { struct Distance { int p1[3]; int p2[3]; double length; }d[50],temp; int n,i,j,k=0; cin>>n; int point[10][3]; double result; for(i=0;i<n;i++) cin>>point[i][0]>>point[i][1]>>point[i][2]; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { d[k].p1[0]=point[i][0]; d[k].p1[1]=point[i][1]; d[k].p1[2]=point[i][2]; d[k].p2[0]=point[j][0]; d[k].p2[1]=point[j][1]; d[k].p2[2]=point[j][2]; result=(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]); d[k].length=sqrt(result*1.0); k++; } for(i=0;i<k-1;i++) for(j=0;j<k-1-i;j++) if(d[j].length<d[j+1].length) {temp=d[j];d[j]=d[j+1];d[j+1]=temp;} for(i=0;i<k;i++) cout<<"("<<d[i].p1[0]<<","<<d[i].p1[1]<<","<<d[i].p1[2]<<")"<<"-"<<"("<<d[i].p2[0]<<","<<d[i].p2[1]<<","<<d[i].p2[2]<<")"<<"="<<fixed<<setprecision(2)<<d[i].length<<endl; return 0; }
64
31935
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
31936
int main() { int i,j,k,n,t,a[150],b[150],x[11],y[11],z[11]; double r,c[150]; cin>>n; for (i=1;i<=n;i++) cin>>x[i]>>y[i]>>z[i]; t=0; for (i=1;i<=n-1;i++) for (j=i+1;j<=n;j++) { t++; a[t]=i;b[t]=j; c[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]) ); } for (i=1;i<=t-1;i++) for (j=1;j<=t-i;j++) if (c[j+1]>c[j]) { k=a[j+1];a[j+1]=a[j];a[j]=k; k=b[j+1];b[j+1]=b[j];b[j]=k; r=c[j+1];c[j+1]=c[j];c[j]=r; } cout<<fixed; 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]] <<")=" <<setprecision(2)<<c[i]<<endl; cin>>i; return 0; }
64
31937
int main () { int n=0,p=0,s=0,m=0; //n?????p????????s??????????m?????????? cin>>n; double t=0; //t???????????????????double? int a[10][3],b[45][6],d[45]; //a????????b?????????????d???b????? double c[45]; //c???????? for (int i=0;i<n;i++) //???????? for (int j=0;j<3;j++) cin>>a[i][j]; for (int i=0;i<n-1;i++) //????????????b for (int j=i+1;j<n;j++) { for (int k=0;k<3;k++) { b[p][k]=a[i][k]; b[p][k+3]=a[j][k]; } c[p]=sqrt((double)((b[p][0]-b[p][3])*(b[p][0]-b[p][3])+(b[p][1]-b[p][4])*(b[p][1]-b[p][4])+(b[p][2]-b[p][5])*(b[p][2]-b[p][5])));//?????????c d[p]=p; //???d??b???? p=p+1; } for (int i=0;i<p-1;i++) for (int j=0;j<p-1-i;j++) { if (c[j]<c[j+1]) { t=c[j];c[j]=c[j+1];c[j+1]=t; s=d[j];d[j]=d[j+1];d[j+1]=s;//????????????????????????????????? } } for (int i=0;i<p;i++) { m=d[i]; cout<<"("<<b[m][0]<<","<<b[m][1]<<","<<b[m][2]<<")-("<<b[m][3]<<","<<b[m][4]<<","<<b[m][5]<<")="; printf ("%.2f",c[i]);cout<<endl; } return 0; }
64
31938
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
31939
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
31940
double num[46][8]; struct node { int a,b,c; int arr[11]; }; struct node arr[11]; int main() { int i,n,j,m; struct node arr[11]; while(scanf("%d",&n)!=EOF) { memset(num,0,sizeof(num)); memset(arr,0,sizeof(arr)); for(i=0;i<n;i++) scanf("%d %d %d",&arr[i].a,&arr[i].b,&arr[i].c); int h=0,k=0; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { double aa,bb,cc,dd; aa=pow((double) (arr[i].a-arr[j].a),(int) 2); bb=pow((double) (arr[i].b-arr[j].b),(int) 2); cc=pow((double) (arr[i].c-arr[j].c),(int) 2); dd= sqrt((double)(aa+bb+cc)); num[h][0]=arr[i].a; num[h][1]=arr[i].b; num[h][2]=arr[i].c; num[h][3]=arr[j].a; num[h][4]=arr[j].b; num[h][5]=arr[j].c; num[h][6]=dd; num[h][7]=k; k++; h++; } for(i=0;i<h-1;i++) for(j=i+1;j<h;j++) if(num[i][6]<=num[j][6]) { double d1=0; for(m=0;m<=6;m++) { d1=num[i][m]; num[i][m]=num[j][m]; num[j][m]=d1; } } for(i=0;i<h-1;i++) for(j=i+1;j<h;j++) if(num[i][6]==num[j][6]) { if(num[i][7]<num[j][7]) { double d1=0; for(m=0;m<=7;m++) { d1=num[i][m]; num[i][m]=num[j][m]; num[j][m]=d1; } } } for(i=0;i<h;i++) printf("(%.f,%.f,%.f)-(%.f,%.f,%.f)=%.2f\n",num[i][0],num[i][1],num[i][2],num[i][3], num[i][4],num[i][5],num[i][6]); } return 0; }
64
31941
void swap(int *a,int *b) { int temp; temp=*a; *a=*b; *b=temp; } void main() { int a[10][3],n,i,j,k=0,b[50][10],N; 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(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]; b[k++][6]=(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]); } } N=k; for(i=1;i<N;i++) { for(j=0;j<N-i;j++) { if(b[j][6]<b[j+1][6]) { swap(&b[j][0],&b[j+1][0]); swap(&b[j][1],&b[j+1][1]); swap(&b[j][2],&b[j+1][2]); swap(&b[j][3],&b[j+1][3]); swap(&b[j][4],&b[j+1][4]); swap(&b[j][5],&b[j+1][5]); swap(&b[j][6],&b[j+1][6]); } } } for(i=0;i<N;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",b[i][0],b[i][1],b[i][2],b[i][3],b[i][4],b[i][5],sqrt(b[i][6])); }
64
31942
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
31943
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
31944
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
31945
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
31946
int main() { int n,i,j,x1=0,x2=0,q=0,w1,w2,w3,w4,w5,w6,t,k,m=1,p=1,l=0,g; scanf("%d",&n); int a[10][3],c[1000],d[1000],e[1000],c1[1000],d1[1000],e1[1000],c2[1000]={0}; float b[1000]={0}; float x,y; for(int i1=0;i1<=n-1;i1++) { scanf("%d %d %d",&a[i1][0],&a[i1][1],&a[i1][2]); } for(x1=0;x1<=n-2;x1++) { for(x2=x1+1;x2<=n-1;x2++) { b[q]=sqrt((float)((a[x2][0]-a[x1][0])*(a[x2][0]-a[x1][0])+(a[x2][1]-a[x1][1])*(a[x2][1]-a[x1][1])+(a[x2][2]-a[x1][2])*(a[x2][2]-a[x1][2]))); c[q]=a[x1][0]; d[q]=a[x1][1]; e[q]=a[x1][2]; c1[q]=a[x2][0]; d1[q]=a[x2][1]; e1[q]=a[x2][2]; q++; } } for(i=q-1;i>=1;i--) { for(j=i-1;j>=0;j--) { if(b[i]>=b[j]) { x=b[i]; b[i]=b[j]; b[j]=x; w1=c[i]; w2=d[i]; w3=e[i]; w4=c1[i]; w5=d1[i]; w6=e1[i]; c[i]=c[j]; d[i]=d[j]; e[i]=e[j]; c1[i]=c1[j]; d1[i]=d1[j]; e1[i]=e1[j]; c[j]=w1; d[j]=w2; e[j]=w3; c1[j]=w4; d1[j]=w5; e1[j]=w6; } } } for(int h=0;h<=q-1;h++) { if(b[h]!=b[h+1]) {c2[p]=h; p++;} } for(int h1=999;h1>=0;h1--) { if(c2[h1]>0) {g=h1;break;} } if(g<1) {g=1;} c2[0]=-1; for(int x4=0;x4<=g-1;x4++) { for(int x5=c2[x4]+1;x5<=c2[x4+1];x5++) { k=c2[x4]+1+c2[x4+1]-x5; printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",c[k],d[k],e[k],c1[k],d1[k],e1[k],b[k]); } } return 0; }
64
31947
int main(){ int n,i,j,k,m,q; j=0; scanf("%d",&n); int a[10],b[10],c[10],f[50],g[50],h[50],l[50],o[50],p[50]; double d[50]; double e; for(i=0;i<n;i++){ scanf("%d %d %d",&a[i],&b[i],&c[i]); } for(i=0;i<n;i++){ for(m=i+1;m<n;m++){ e=(a[i]-a[m])*(a[i]-a[m])+ (b[i]-b[m])*(b[i]-b[m])+ (c[i]-c [m])*(c[i]-c[m]); d[j]=sqrt(e); f[j]=a[i]; g[j]=b[i]; h[j]=c[i]; l[j]=a[m]; o[j]=b[m]; p[j]=c[m]; j=j+1; } } for(k = 1 ; k <= j ; k++){ for(i = 0; i < j- k; i++){ if(d[i] < d[i+1]){ e = d[i+1]; d[i+1] = d[i]; d[i] = e; q= f[i+1]; f[i+1] = f[i]; f[i] = q; q= g[i+1]; g[i+1] = g[i]; g[i] = q; q= h[i+1]; h[i+1] = h[i]; h[i] = q; q= l[i+1]; l[i+1] = l[i]; l[i] = q; q= o[i+1]; o[i+1] = o[i]; o[i] = q; q= p[i+1]; p[i+1] =p[i]; p[i] = q; } } } for(i=0;i<j;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",f[i],g[i],h[i],l[i], o[i],p[i],d[i]); } return 0; }
64
31948
//******************************************************** //* ???:1.cpp * //* ?????? 1200012948 * //* ????: 2012 12 09 * //* ????:???? * //******************************************************** struct shuju //???????????????? { int xx; int yy; double dis; } sj[100], temp; struct distance //???????? { int x; int y; int z; }point[10]; int main() { int n, i, j, k = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> point[i].x >> point[i].y >> point[i].z; } for (i = 1; i < n; i++) for(j = i + 1; j <= n; j++) { k++; double m = (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); sj[k].dis = sqrt(m); sj[k].xx = i; sj[k].yy = j; } for (i = 1; i < n * (n - 1) / 2; i++) //?? for (j = 1; j <= n * (n - 1) / 2 - i; j++) { if (sj[j].dis < sj[j + 1].dis) { temp =sj[j]; sj[j] = sj[j + 1]; sj[j + 1] = temp; } } for (i = 1; i <= n * (n - 1) / 2; i++) { cout << "(" << point[sj[i].xx].x << "," << point[sj[i].xx].y << "," << point[sj[i].xx].z << ")" << "-" << "(" << point[sj[i].yy].x << "," << point[sj[i].yy].y << "," << point[sj[i].yy].z << ")" << "=" << fixed << setprecision(2) << sj[i].dis << endl; } return 0; }
64
31949
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
31950
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
31951
void main() { int m,n,i,j,k,a,c,t,u; int tt[100][3]; int pp[10000][6]; float xx[10000],b; scanf("%d",&m); for(i=0;i<m;i++) { for(u=0;u<3;u++) { scanf("%d",&tt[i][u]); } } n=m*(m-1)/2; t=n; for(a=0,j=0;j<m-1;j++) { for(k=j+1;k<m;k++,a++) { xx[a]=sqrt((tt[j][0]-tt[k][0])*(tt[j][0]-tt[k][0])+(tt[j][1]-tt[k][1])*(tt[j][1]-tt[k][1])+(tt[j][2]-tt[k][2])*(tt[j][2]-tt[k][2])); pp[a][0]=tt[j][0]; pp[a][1]=tt[j][1]; pp[a][2]=tt[j][2]; pp[a][3]=tt[k][0]; pp[a][4]=tt[k][1]; pp[a][5]=tt[k][2]; } } for(i=0;i<n-1;n--) { for(j=i;j<n-1;j++) { if(xx[j]<xx[j+1]) { b=xx[j]; xx[j]=xx[j+1]; xx[j+1]=b; c=pp[j][0]; pp[j][0]=pp[j+1][0]; pp[j+1][0]=c; c=pp[j][1]; pp[j][1]=pp[j+1][1]; pp[j+1][1]=c; c=pp[j][2]; pp[j][2]=pp[j+1][2]; pp[j+1][2]=c; c=pp[j][3]; pp[j][3]=pp[j+1][3]; pp[j+1][3]=c; c=pp[j][4]; pp[j][4]=pp[j+1][4]; pp[j+1][4]=c; c=pp[j][5]; pp[j][5]=pp[j+1][5]; pp[j+1][5]=c; } } } for(k=0;k<t;k++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",pp[k][0],pp[k][1],pp[k][2],pp[k][3],pp[k][4],pp[k][5],xx[k]); } }
64
31952
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
31953
int zuob[12][3]; //??? int vis[12][12]; int main() { // freopen("1.in","r",stdin); // freopen("1.out","w",stdout); double distance[12][12]; memset(vis,sizeof(vis),0); int n;int ii,jj; cin >> n; for(int i=0;i<n;i++) cin >> zuob[i][0] >> zuob[i][1] >> zuob[i][2]; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) distance[i][j]=sqrt((zuob[i][0]-zuob[j][0])*(zuob[i][0]-zuob[j][0])+(zuob[i][1]-zuob[j][1])*(zuob[i][1]-zuob[j][1])+(zuob[i][2]-zuob[j][2])*(zuob[i][2]-zuob[j][2])); for(int z=0;z<(n*(n-1)/2);z++) {double max=-1; for(int i=0;i<n-1;i++) for(int j=i+1;j<n;j++) if(vis[i][j]==0 && distance[i][j]>max) {max=distance[i][j];ii=i;jj=j;} cout<<"("<<zuob[ii][0]<<","<<zuob[ii][1]<<","<<zuob[ii][2]<<")" <<"-"<<"("<<zuob[jj][0]<<","<<zuob[jj][1]<<","<<zuob[jj][2]<<")" <<"="; printf("%.2lf\n",max); vis[ii][jj]=1; } return 0; }
64
31954
int main() { int n , c ; cin >> n ; //??? int x[n] , y[n] , z[n] ; c = n * ( n - 1 ) / 2 ; //???? int a[c] , b[c] ; // ???????????????????? double l[c] ; //???? for( int i = 0 ; i < n ; i ++ ) //?? { cin >> x[i] >> y[i] >> z[i] ; } c = -1 ; for( int i = 0 ; i < n - 1 ; i ++ ) //??????? for( int j = i + 1 ; j < n ; j ++ ) { c ++ ; a[c] = i ; b[c] = j ; l[c] = 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 t1 = 0 ; int t = 0 ; for( int i = 0 ; i <= c ; i ++ ) //?????????????? for( int j = 0 ; j <= c - 1 - i ; j ++ ) { if( l[j] < l[j+1] ) { t1 = l[j] ; l[j] = l[j+1] ; l[j+1] = t1 ; t = a[j] ; a[j] = a[j+1] ; a[j+1] = t ; t = b[j] ; b[j] = b[j+1] ; b[j+1] = t ; } } cout << fixed << setprecision(2) ; //???????? for( int i = 0 ; i <= c ; i ++ ) { cout << "(" << x[a[i]] << "," << y[a[i]] << "," << z[a[i]] << ")-(" << x[b[i]] << "," << y[b[i]] << "," << z[b[i]] << ")=" << l[i] << endl ; } return 0 ; }
64
31955
//============================================================================ // 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
31956
/* ????????.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
31957
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
31958
int main() { int n,i,j,k=0,x[10],y[10],z[10],a[90],b[90];//n:??,i,j,k=0,?????x[10],y[10],z[10]????x?y?z??,a[90],b[90]????????? double l[90],p;//l[90]:???p:????????? cin>>n; for(i=0;i<n;i++) cin>>x[i]>>y[i]>>z[i]; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { l[k]=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[k]=i; b[k]=j; k++; } for(i=1;i<k;i++) for(j=0;j<k-i;j++) { if(l[j]<l[j+1]) { p=l[j]; l[j]=l[j+1]; l[j+1]=p; p=a[j]; a[j]=a[j+1]; a[j+1]=p; p=b[j]; b[j]=b[j+1]; b[j+1]=p; } } for(i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],l[i]); return 0; }
64
31959
struct point{ int x; int y; int z; }; struct distanceBetweenPoints{ int pointIndex1; int pointIndex2; double distace; }; double distance(struct point p1, struct point p2){ double d =0.0; d = 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)); return d; } int main(int argc, const char * argv[]) { int n; scanf("%d", &n); struct point points[n]; for (int j=0; j<n; j++) { scanf("%d %d %d", &points[j].x, &points[j].y, &points[j].z); } struct distanceBetweenPoints distances[n*(n-1)/2]; int index = 0; for (int index1=0; index1<n; index1++) { for (int index2=index1+1; index2<n; index2++) { double d = distance(points[index1], points[index2]); distances[index].distace = d; distances[index].pointIndex1 = index1; distances[index].pointIndex2 = index2; index ++; } } for (int i=0; i<index; i++) { for (int j=1; j<index-i; j++) { if (distances[j-1].distace < distances[j].distace) { struct distanceBetweenPoints temp; temp = distances[j-1]; distances[j-1] = distances[j]; distances[j] = temp; } } } for (int i = 0; i < index; i++) { printf("(%d,%d,%d)",points[distances[i].pointIndex1].x, points[distances[i].pointIndex1].y, points[distances[i].pointIndex1].z); printf("-"); printf("(%d,%d,%d)",points[distances[i].pointIndex2].x, points[distances[i].pointIndex2].y, points[distances[i].pointIndex2].z); printf("="); printf("%.2lf\n", distances[i].distace); } return 0; }
64
31960
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
31961
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
31962
/** *@ 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
31963
/*?????? ????????n??????10??,??n?????????, ??????????????????????????? ???? ????????????????n??????????????????(??????)? ????????0?100???????????????? ???? ?????n????????n*(n-1)/2??????????? (x1,y1,z1)-(x2,y2,z2)=?? ???????????2?? */ int main() { int n;cin>>n; int x[n+1],y[n+1],z[n+1];float dst[n*n]; int sma[n*n], lar[n*n];//dst=distance;sma??????lar?dst??,??????????? int count=0; float t; for( int i=1; i<=n; ++i ) { cin>>x[i]>>y[i]>>z[i]; } for( int e=1; e<=n; e++ )for(int e1=e+1; e1<=n; ++e1 ) { ++count; sma[count]=e;lar[count]=e1; dst[count]=sqrt((x[e]-x[e1])*(x[e]-x[e1])+(y[e]-y[e1])*(y[e]-y[e1])+(z[e]-z[e1])*(z[e]-z[e1])); } for(int e=1; e<=count-1; ++e )//??? for( int i=1; i<=count-e ;++i ) { if ( dst[i]<dst[i+1] ) { t=dst[i]; dst[i]=dst[i+1]; dst[i+1]=t; t=sma[i]; sma[i]=sma[i+1]; sma[i+1]=(int)t; t=lar[i]; lar[i]=lar[i+1]; lar[i+1]=(int)t; } } for ( int e=1; e<=count ; ++e ) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[sma[e]],y[sma[e]],z[sma[e]],x[lar[e]],y[lar[e]],z[lar[e]],dst[e]); return 0; }
64
31964
struct point{ int x; int y; int z; }; int main(){ int n,i,j,k=0,c; double R[1000]; double t; struct point A[10],B[100],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++){ B[k].x=A[i].x;B[k].y=A[i].y;B[k].z=A[i].z; C[k].x=A[j].x;C[k].y=A[j].y;C[k].z=A[j].z; R[k]=sqrt(pow(1.0*(B[k].x-C[k].x),2)+pow(1.0*(B[k].y-C[k].y),2)+pow(1.0*(B[k].z-C[k].z),2)); k++; } } for(i=0;i<k;i++){ for(j=k-1;j>i;j--){ if(R[j]>R[j-1]){ t=R[j]; R[j]=R[j-1];R[j-1]=t; c=B[j].x;B[j].x=B[j-1].x;B[j-1].x=c; c=B[j].y;B[j].y=B[j-1].y;B[j-1].y=c; c=B[j].z;B[j].z=B[j-1].z;B[j-1].z=c; c=C[j].x;C[j].x=C[j-1].x;C[j-1].x=c; c=C[j].y;C[j].y=C[j-1].y;C[j-1].y=c; c=C[j].z;C[j].z=C[j-1].z;C[j-1].z=c; } } } 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,R[i]); } return 0; }
64
31965
int x[11],y[11],z[11],cnt,n,dist[105]; int getdist(int i,int j){ return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); } int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>z[i]; for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) dist[++cnt]=getdist(i,j); sort(dist+1,dist+1+cnt); //???? ???? for(int k=cnt;k>=1;k--)if(dist[k]!=dist[k-1]) //?????????????? for(int i=1;i<n;i++) for(int j=i+1;j<=n;j++) if(getdist(i,j)==dist[k]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],(double)(sqrt(dist[k])));//???? ???????? return 0; }
64
31966
int main(){ int n,sf; scanf("%d",&n); int k=0; int x[10],y[10],z[10],a[200],b[200]; double s[200]; 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(int j=i+1;j<n;j++){ sf=(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[k]=sqrt(sf); a[k]=i; b[k]=j; k++; } } int l; double u; for(int q=1;q<k;q++){ for(int w=0;w<k-q;w++){ if(s[w]<s[w+1]){ u=s[w]; s[w]=s[w+1]; s[w+1]=u; l=a[w]; a[w]=a[w+1]; a[w+1]=l; l=b[w]; b[w]=b[w+1]; b[w+1]=l; } } } for(int 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]],s[i]); } return 0; }
64
31967
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
31968
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
31969
//********************** //* ??? ???? * //* 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
31970
int main() { int n,b,c; scanf("%d",&n); int i,j,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],k,y[51],z[51]; double l[51]; 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++; } } int e,g; double f; for(k=1;k<=i;k++) { for(j=0;j<(i-k);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(j=0;j<i;j++) { b=y[j]; c=z[j]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sa[b],sb[b],sc[b],sa[c],sb[c],sc[c],l[j]); } return 0; }
64
31971
int main() { int n, j, i, k = 0, m; float p = 0, a[100] = { 0 }; int x[10], y[10], z[10]; float s[10][10] = { 0 }; cin >> n; for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i]; for (i = 0; i < n; i++) {//???? for (j = i + 1; j < n; j++) { a[k++] = s[i][j] = (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 = 0; i < k - 1; i++) {//?? for (j = 0; j < k - 1 - i; j++) { if (a[j] < a[j + 1]) { p = a[j]; a[j] = a[j + 1]; a[j + 1] = p; } } } for (j = 0; j < n; j++) { for (i = 0; i < n; i++) { if (a[0] == s[i][j]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", x[i], y[i], z[i], x[j], y[j], z[j], sqrt(a[0])); } } for (m = 1; m < k; m++) { for (j = 0; j < n; j++) { for (i = 0; i < n; i++) { if (a[m] == s[i][j] && a[m] != a[m - 1]) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", x[i], y[i], z[i], x[j], y[j], z[j], sqrt(a[m])); } } } return 0; }
64
31972
int main(){ int n,a[10],b[10],c[10],i; double d[10][10],e[45]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); } int k,t=0; for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ d[i][k]=sqrt((a[i]-a[k])*(a[i]-a[k])+(b[i]-b[k])*(b[i]-b[k])+(c[i]-c[k])*(c[i]-c[k])); e[t]=d[i][k]; t++; } } for(t=0;t<n*(n-1)/2-1;t++){ for(i=n*(n-1)/2-1;i>t;i--){ if(e[i]>e[i-1]){ double m; m=e[i]; e[i]=e[i-1]; e[i-1]=m; } } } for(t=0;t<n*(n-1)/2;t++){ for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ if(d[i][k]==e[t]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],a[k],b[k],c[k],e[t]); d[i][k]=0; k=n; i=n; } } } } return 0; }
64
31973
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
31974
int main() { int n; cin>>n; float x[n],y[n],z[n],a[(n-1)*n/2],va; for(int i=0;i<n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(int i=0,k=0;i<n-1;i++) { for(int j=i+1;j<n;j++) { a[k]=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])); k=k+1; } } for(int i=0;i<(n-1)*n/2-1;i++) { for(int j=0;j<(n-1)*n/2-1-i;j++) { if(a[j]<=a[j+1]) { va=a[j]; a[j]=a[j+1]; a[j+1]=va; } } } for(int i=0;i<(n-1)*n/2;i++) { if((a[i]==a[i+1])&&(i!=(n-1)*n/2-1)) continue; else { for(int j=0;j<n-1;j++) { for(int k=j+1;k<n;k++) { if(a[i]==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]))) { if(i==0) printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f",x[j],y[j],z[j],x[k],y[k],z[k],a[i]); else printf("\n(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f",x[j],y[j],z[j],x[k],y[k],z[k],a[i]); } } } } } return 0; }
64
31975
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
31976
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
31977
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
31978
int main() { int n,j=0,b; int a[15][3]; double s[10000]; int x[10000][2]; double p; cin>>n; for(int i=0;i<n;i++) { cin>>a[i][0]>>a[i][1]>>a[i][2]; } for(int k=0;k<n-1;k++) { for(int m=k+1;m<n;m++) { s[j]=sqrt((a[k][0]-a[m][0])*(a[k][0]-a[m][0])+(a[k][1]-a[m][1])*(a[k][1]-a[m][1])+(a[k][2]-a[m][2])*(a[k][2]-a[m][2])); x[j][0]=k; x[j][1]=m; j++; } } for(int z=0;z<j-1;z++) { for(int d=0;d<j-1-z;d++) { if(s[d]<s[d+1]) { p=s[d+1]; s[d+1]=s[d]; s[d]=p; b=x[d+1][0]; x[d+1][0]=x[d][0]; x[d][0]=b; b=x[d+1][1]; x[d+1][1]=x[d][1]; x[d][1]=b; } } } for(int g=0;g<j;g++) { cout<<"("<<a[x[g][0]][0]<<","<<a[x[g][0]][1]<<","<<a[x[g][0]][2]<<")"<<"-"<<"("<<a[x[g][1]][0]<<","<<a[x[g][1]][1]<<","<<a[x[g][1]][2]<<")"<<"="<<fixed<<setprecision(2)<<s[g]<<endl; } return 0; }
64
31979
struct distance { int sp1x; int sp1y; int sp1z; int sp2x; int sp2y; int sp2z; double dis; } dis[999999],temp; int main() { int n,spot[9999][3]={0},t=0; cin>>n; for (int i=0;i<n;i++) cin>>spot[i][0]>>spot[i][1]>>spot[i][2]; for (int i=0;i<n-1;i++) for (int j=i+1;j<n;j++) { dis[t].sp1x=spot[i][0]; dis[t].sp1y=spot[i][1]; dis[t].sp1z=spot[i][2]; dis[t].sp2x=spot[j][0]; dis[t].sp2y=spot[j][1]; dis[t].sp2z=spot[j][2]; dis[t].dis=sqrt(pow(spot[i][0]-spot[j][0],2.0) + pow(spot[i][1]-spot[j][1],2.0) + pow(spot[i][2]-spot[j][2],2.0)); t++; } for (int i=0;i<=t-2;i++) for (int j=0;j<=t-2-i;j++) if (dis[j].dis<dis[j+1].dis) { temp=dis[j]; dis[j]=dis[j+1]; dis[j+1]=temp; } for (int i=0;i<t;i++) cout<<"("<<dis[i].sp1x<<","<<dis[i].sp1y<<","<<dis[i].sp1z<<")-("<<dis[i].sp2x<<","<<dis[i].sp2y<<","<<dis[i].sp2z<<")=" <<fixed<<setprecision(2)<<dis[i].dis<<endl; return 0; }
64
31980
struct point {int x; int y; int z; }p[10]; void distance(int n) {int i,j,k=0; double t,d[10][10]={0},D[45]={0}; 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]);}}}} } int main() { int n,i; scanf("%d",&n); for(i=0;i<n;i++) {scanf("%d%d%d",&p[i].x,&p[i].y,&p[i].z);} distance(n); return 0; }
64
31981
int main() { typedef struct { int a[3]; int b[3]; float dis; } juli; int n,m=0,i,j,k,x,y; scanf("%d",&n); int c[10][3]; for(i=0;i<n;i++) scanf("%d %d %d",&c[i][0],&c[i][1],&c[i][2]); juli d[50]; juli temp; for(i=0;i<n-1;i++) {for(j=i+1;j<n;j++) { x=0; for(k=0;k<3;k++) { d[m].a[k]=c[i][k]; d[m].b[k]=c[j][k]; x+=(c[i][k]-c[j][k])*(c[i][k]-c[j][k]); } d[m].dis=sqrt(fabs(x)); m++; }} k=m; for(;m;m--) { for(i=0;i<m-1;i++) { if(d[i].dis<d[i+1].dis) { temp=d[i]; d[i]=d[i+1]; d[i+1]=temp; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",d[i].a[0],d[i].a[1],d[i].a[2],d[i].b[0],d[i].b[1],d[i].b[2],d[i].dis); } }
64
31982
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
31983
int main() { int n,i,j,a[80],b[80],k=0,m,code1,code2; double S[80],t; struct S { double x; double y; double z; }point[13]; 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++)//????Cn2 { S[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));//??? a[k]=i;b[k]=j; k++;// } for(i=0;i<k;i++) for(j=k-1;j>i;j--)//????? if(S[j]>S[j-1]) { t=S[j]; S[j]=S[j-1]; S[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<k;i++) { code1=a[i];code2=b[i]; cout<<"("<<(int)point[code1].x<<","<<(int)point[code1].y<<","<<point[code1].z<<")-(" <<(int)point[code2].x<<","<<(int)point[code2].y<<","<<point[code2].z<<")="; printf("%.2lf",S[i]); cout<<endl; } return 0; }
64
31984
int main() { int n, l = 0; struct point { int x; int y; int z; }a[10]; struct distance { int m[3]; int n[3]; double dis; }temp,b[100]; cin>>n; for(int i=0;i<n;i++) { cin>>a[i].x>>a[i].y>>a[i].z; } for(int i=0;i<n-1;i++) { for(int j=i+1;j<n;j++) { b[l].m[0] = a[i].x; b[l].m[1] = a[i].y; b[l].m[2] = a[i].z; b[l].n[0] = a[j].x; b[l].n[1] = a[j].y; b[l].n[2] = a[j].z; b[l].dis = sqrt( ( a[j].x - a[i].x ) * ( a[j].x - a[i].x ) + ( a[j].y - a[i].y ) * ( a[j].y - a[i].y ) + ( a[j].z - a[i].z ) * ( a[j].z - a[i].z ) ); l++; } } for(int i=0;i<n*(n-1)/2-1;i++) { for(int j=0;j<n*(n-1)/2-1;j++) { if(b[j].dis<b[j+1].dis) { temp=b[j]; b[j]=b[j+1]; b[j+1]=temp; } } } for(int i=0;i<n*(n-1)/2;i++) { cout<<"("<<b[i].m[0]<<","<<b[i].m[1]<<","<<b[i].m[2]<<")-(" <<b[i].n[0]<<","<<b[i].n[1]<<","<<b[i].n[2]<<")="<<fixed<<setprecision(2)<<b[i].dis<<endl; } return 0; }
64
31985
int fang(int x,int y) { float z; z=(x-y)*(x-y); return(z); } struct dian { int c; int d; float e; }jl[100],tem; void main() { struct dian ji[100]; struct dian tem; int fang(int x,int y); int a[10][3],n,i,j,k=0; for(i=0;i<100;i++){ jl[i].c=0; jl[i].d=0; jl[i].e=0; } 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++){ jl[k].c=i; jl[k].d=j; jl[k].e=(float)sqrt(fang(a[i][0],a[j][0])+fang(a[i][1],a[j][1])+fang(a[i][2],a[j][2])); k++; } } for(j=0;j<k-1;j++){ for(i=0;i<k-1-j;i++){ if(jl[i].e<jl[i+1].e){ tem=jl[i]; jl[i]=jl[i+1]; jl[i+1]=tem; } } } for(i=0;;i++){ if(jl[i].e==0) break; printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[jl[i].c][0],a[jl[i].c][1],a[jl[i].c][2],a[jl[i].d][0],a[jl[i].d][1],a[jl[i].d][2],jl[i].e); } }
64
31986
int main() { int p[10][3],d2[10][10]; float d[10][10]; int i,j,k=0,n,N; scanf("%d",&n); for(i=0;i<n;i++) for(j=0;j<3;j++) scanf("%d",&p[i][j]); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { d2[i][j]=(p[i][0]-p[j][0])*(p[i][0]-p[j][0])+(p[i][1]-p[j][1])*(p[i][1]-p[j][1])+(p[i][2]-p[j][2])*(p[i][2]-p[j][2]); d[i][j]=sqrt((float)d2[i][j]); } struct {float d;int p1;int p2;}A[46]; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { A[k].d=d[i][j]; A[k].p1=i; A[k].p2=j; k++; } N=k; for(k=0;k<N;k++) for(j=0;j<N-1-k;j++) if(A[j].d<A[j+1].d) { A[45]=A[j]; A[j]=A[j+1]; A[j+1]=A[45]; } for(k=0;k<N;k++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",p[A[k].p1][0],p[A[k].p1][1],p[A[k].p1][2],p[A[k].p2][0],p[A[k].p2][1],p[A[k].p2][2],A[k].d); return 0; }
64
31987
double juli(double m, double n, double l); double juli(double m, double n, double l){ double t; t= m*m+n*n+l*l; t=sqrt(t); return t; } int main(){ int n,i,j,m; scanf("%d",&n); double x[11]; double y[11]; double z[11]; double k[56]; double jiawei1[56]; double jiawei2[56]; double jiawei3[56]; double jianwei1[56]; double jianwei2[56]; double jianwei3[56]; double tran; for(i=1;i<n+1;i++){ scanf("%lf %lf %lf",&x[i],&y[i],&z[i]); } m=1; for(i=1;i<1+n;i++){ for(j=i+1;j<n+1;j++){ k[m]= juli(x[i]-x[j],y[i]-y[j],z[i]-z[j]); jiawei1[m]=x[i]; jiawei2[m]=y[i]; jiawei3[m]=z[i]; jianwei1[m]=x[j]; jianwei2[m]=y[j]; jianwei3[m]=z[j]; m=m+1; } } for(i=1;i<m;i++){ for(j=i;j<m;j++){ if(k[i]<k[j]){ tran=k[i]; k[i]=k[j]; k[j]=tran; tran=jiawei1[i]; jiawei1[i]=jiawei1[j]; jiawei1[j]=tran; tran=jiawei2[i]; jiawei2[i]=jiawei2[j]; jiawei2[j]=tran; tran=jiawei3[i]; jiawei3[i]=jiawei3[j]; jiawei3[j]=tran; tran=jianwei1[i]; jianwei1[i]=jianwei1[j]; jianwei1[j]=tran; tran=jianwei2[i]; jianwei2[i]=jianwei2[j]; jianwei2[j]=tran; tran=jianwei3[i]; jianwei3[i]=jianwei3[j]; jianwei3[j]=tran; } } } int v=1; for(i=1;i<m;i++){ for(j=i;j<m;j++){ if(k[i]==k[j]){ for(v=1;v<n+1;v++){ if( (jiawei1[i]==x[v]&&jiawei1[j]!=x[v]) ||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==y[v]&&jiawei2[j]!=x[v]) ||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==z[v]&&jiawei3[j]!=z[v]) ||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==x[v]&&jianwei1[j]!=x[v]) ||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==jianwei1[j]&&jianwei2[i]==y[v]&&jianwei2[j]!=y[v]) ||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==jianwei1[j]&&jianwei2[i]==jianwei2[j]&&jianwei3[i]==z[v]&&jianwei3[j]!=z[v]) ){ tran=jiawei1[i]; jiawei1[i]=jiawei1[j]; jiawei1[j]=tran; tran=jiawei2[i]; jiawei2[i]=jiawei2[j]; jiawei2[j]=tran; tran=jiawei3[i]; jiawei3[i]=jiawei3[j]; jiawei3[j]=tran; tran=jianwei1[i]; jianwei1[i]=jianwei1[j]; jianwei1[j]=tran; tran=jianwei2[i]; jianwei2[i]=jianwei2[j]; jianwei2[j]=tran; tran=jianwei3[i]; jianwei3[i]=jianwei3[j]; jianwei3[j]=tran; } } } } } for(i=1;i<n*(n-1)/2+1;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",(int)jiawei1[i],(int)jiawei2[i],(int)jiawei3[i],(int)jianwei1[i],(int)jianwei2[i],(int)jianwei3[i],k[i]); } return 0; }
64
31988
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
31989
int main() { float a[100][9],b[20][4],max=0;//1-3???????4-5??????7??? int n,i,j,k=1; cin>>n; for (i=1;i<=n;i++) {for(j=1;j<=3;j++){ cin>>b[i][j]; }} for (i=1;i<=n-1;i++) {for (j=i+1;j<=n;j++) {a[k][1]=b[i][1]; a[k][2]=b[i][2]; a[k][3]=b[i][3]; a[k][4]=b[j][1]; a[k][5]=b[j][2]; a[k][6]=b[j][3]; a[k][7]=sqrt(pow((a[k][1]-a[k][4]),2)+pow((a[k][2]-a[k][5]),2)+pow((a[k][3]-a[k][6]),2)); a[k][8]=0; //?????? k++; } } for(i = 1;i <= (n*n-n)/2;i++){ for (k=1;k<=(n*n-n)/2;k++) { if (a[k][7]>max&&a[k][8]==0) max=a[k][7]; } for (k=1;k<=(n*n-n)/2;k++) {if (max==a[k][7]&&a[k][8]==0){ printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",a[k][1],a[k][2],a[k][3],a[k][4],a[k][5],a[k][6],a[k][7]); a[k][8]=1; max=0; }} } return 0; }
64
31990
/* * 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
31991
typedef struct point{ int x, y, z; } P; typedef struct len{ double real; P *a, *b; } L; P points[10]; L len[1000]; int lencount=0; int cmp(const void *a, const void *b){ double k; L *aa=(L*)a, *bb=(L*)b; if((k=aa->real - bb->real)) return k<0; return aa->a - bb->a; } int main() { int n, i, j; double tmp; scanf("%d", &n); for(i=0; i<n; i++){ scanf("%d", &(points[i].x)); scanf("%d", &(points[i].y)); scanf("%d", &(points[i].z)); } for(i=0; i<n-1; i++){ for(j=i+1; j<n; j++){ tmp=0; tmp+=pow(points[i].x-points[j].x, 2); tmp+=pow(points[i].y-points[j].y, 2); tmp+=pow(points[i].z-points[j].z, 2); len[lencount].real=pow(tmp, 0.5); len[lencount].a=&points[i]; len[lencount].b=&points[j]; lencount++; } } qsort(len, lencount, sizeof(L), cmp); for(i=0; i<lencount; i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", (len[i].a)->x, (len[i].a)->y, (len[i].a)->z, (len[i].b)->x, (len[i].b)->y, (len[i].b)->z, len[i].real); } return 0; }
64
31992
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
31993
//???????? struct point{ int x; int y; int z; }input[10]={0}; struct point u; struct point v; struct total{ struct point u; struct point v; double result; }output[45]={0}; //??????????? double distance(struct point a,struct point b) { return(sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z))); } void sort(struct total c[],int d) { int m,n; struct total temp; for(m=1;m<d;m++) for(n=0;n<d-m;n++) if(c[n].result<c[n+1].result){ temp=c[n]; c[n]=c[n+1]; c[n+1]=temp; } } //??? void main() { int n,i,j,p; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&input[i].x,&input[i].y,&input[i].z); p=-1; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ p++; output[p].u=input[i]; output[p].v=input[j]; output[p].result=distance(output[p].u,output[p].v); } } sort(output,p+1); for(i=0;i<=p;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",output[i].u.x,output[i].u.y,output[i].u.z,output[i].v.x,output[i].v.y,output[i].v.z,output[i].result); }
64
31994
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
31995
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
31996
int main(){ int i,a[1000][3],n,e,j,k=0,h; double m[3000][3],r,p,q; scanf("%d",&n); h=n*(n-1)/2; for(i=0;i<n;i++) { scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { m[k][0]=i; m[k][1]=j; m[k][2]=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]))); k++; } } for(i=1;i<h;i++) { for(k=0;k<h-i;k++) { if(m[k][2]<m[k+1][2]) { r=m[k][0]; m[k][0]=m[k+1][0]; m[k+1][0]=r; p=m[k][1]; m[k][1]=m[k+1][1]; m[k+1][1]=p; q=m[k][2]; m[k][2]=m[k+1][2]; m[k+1][2]=q; } } } for(i=0;i<h;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[(int)m[i][0]][0],a[(int)m[i][0]][1],a[(int)m[i][0]][2],a[(int)m[i][1]][0],a[(int)m[i][1]][1],a[(int)m[i][1]][2],m[i][2]); return 0; }
64
31997
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
31998
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
31999
//*************************** //*???????? * //*? ???? 1100062709 * //*? ??2011.12.11 * //*************************** int main() { int n, i, j, k = 0; cin >> n; //???? int num = n * (n - 1) / 2; //????????? int a[10][3]; //???????? int *p2 = *a; //????????p2????????? for ( i = 0; i < n; i++) for ( j = 0; j < 3; j++) cin >> *p2++; //???? double b[10][10]; double c[45]; //???????????? double *p1 = c; for ( i = 0; i < n - 1; i++) for ( j = i + 1; j < n; j++) { double len1, len2, len3; //?????i???j???? 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); //?i,j??????????b? *p1++ = b[i][j]; //?i,j??????????c? } p1 = c; //??p1????c????? double temp; for(i = 0; i < num - 1; i++) //?????c???? for (j = 0; j < num - 1 - i; j++) { if (*(p1 + j) < *(p1 + j + 1) ) { temp = *(p1 + j); *(p1 + j) = *(p1 + j + 1); *(p1 + j + 1) = temp; } } for (k = 0; k < num; k++) { if (k == 0) //k=0??c[k]?????? { for ( i = 0; i < n; i++) for ( j = i + 1; j < n; j++) if (fabs(b[i][j] - c[k]) < 1e-9) //??b[i][j]?c[k]???????????? { 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 //?c[k]??????? { 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; }