id
int32
0
32.5k
code
stringlengths
95
8.4k
label
stringclasses
65 values
31,500
double distance(int xa,int ya,int za,int xb,int yb,int zb); double distance(int xa,int ya,int za,int xb,int yb,int zb){ int sum; double dis; sum=(xb-xa)*(xb-xa)+(yb-ya)*(yb-ya)+(zb-za)*(zb-za); dis=sqrt(sum); return dis; } int main(){ int n,i,t,j,b=0,w=0,te; double td; scanf("%d",&n); struct point{ int x,y,z; }point[10]; for(i=0;i<n;i++) scanf("%d %d %d",&point[i].x,&point[i].y,&point[i].z); struct{ int p,q; double dist; }temp[45]; for(i=0;i<45;i++) temp[i].dist=-1; for(i=0;i<n;i++) for(j=0;j<i;j++){ temp[w].p=i; temp[w].q=j; temp[w].dist=distance(point[i].x,point[i].y,point[i].z,point[j].x,point[j].y,point[j].z); w=w+1; } for(i=0;i<45;i++) for(w=0;w<44;w++) if(temp[w].dist<temp[w+1].dist) { te=temp[w+1].p; temp[w+1].p=temp[w].p; temp[w].p=te; te=temp[w+1].q; temp[w+1].q=temp[w].q; temp[w].q=te; td=temp[w+1].dist; temp[w+1].dist=temp[w].dist; temp[w].dist=td; } for(w=0;w<45;w++){ if(temp[w].p>temp[w].q){ te=temp[w].q; temp[w].q=temp[w].p; temp[w].p=te; } if(temp[w].dist!=-1) { printf("(%d,%d,%d)-",point[temp[w].p].x,point[temp[w].p].y,point[temp[w].p].z); printf("(%d,%d,%d)=",point[temp[w].q].x,point[temp[w].q].y,point[temp[w].q].z); printf("%.2lf\n",temp[w].dist); } } return 0; }
64
31,501
int main() { int n,i,s,j; struct point { int a,b,c; }p[10]; struct distance { double d; int x1,x2,y1,y2,z1,z2; }dis[45],temp; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&p[i].a,&p[i].b,&p[i].c); i=0; j=1; for(s=0;s<n*(n-1)/2;s++) { dis[s].x1=p[i].a; dis[s].x2=p[j].a; dis[s].y1=p[i].b; dis[s].y2=p[j].b; dis[s].z1=p[i].c; dis[s].z2=p[j].c; j++; if(j==n) { i++; j=i+1; } } for(s=0;s<n*(n-1)/2;s++) dis[s].d=sqrt((dis[s].x1-dis[s].x2)*(dis[s].x1-dis[s].x2)+(dis[s].y1-dis[s].y2)*(dis[s].y1-dis[s].y2)+(dis[s].z1-dis[s].z2)*(dis[s].z1-dis[s].z2)); for(j=1;j<n*(n-1)/2;j++) { for(i=0;i<n*(n-1)/2-j;i++) { if(dis[i].d<dis[i+1].d) { temp=dis[i]; dis[i]=dis[i+1]; dis[i+1]=temp; } } } for(s=0;s<n*(n-1)/2;s++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dis[s].x1,dis[s].y1,dis[s].z1,dis[s].x2,dis[s].y2,dis[s].z2,dis[s].d); return 0; }
64
31,502
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
31,503
struct suanshi{ int a[3],b[3]; int no; float x; }dian[45]; int cmp(const void *a,const void *b){ struct suanshi *aa=(struct suanshi *)a; struct suanshi *bb=(struct suanshi *)b; if((aa->x)<(bb->x))return 1; if((aa->x)>(bb->x))return -1; else return (aa->no)-(bb->no); } void main(){ int point[11][3]; int n,i,j,t=0; scanf("%d",&n); for(i=0;i<n;i++)scanf("%d%d%d",&point[i][0],&point[i][1],&point[i][2]); for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ dian[t].no=t+1; dian[t].a[0]=point[i][0];dian[t].a[1]=point[i][1];dian[t].a[2]=point[i][2]; dian[t].b[0]=point[j][0];dian[t].b[1]=point[j][1];dian[t].b[2]=point[j][2]; dian[t].x=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])); t++; } } for(j=0;n>0;){ n--; j+=n; } qsort(dian,j,sizeof(struct suanshi),cmp); for(i=0;i<j;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dian[i].a[0],dian[i].a[1],dian[i].a[2],dian[i].b[0],dian[i].b[1],dian[i].b[2],dian[i].x); }
64
31,504
int main() { double n,x[100],y[100],z[100],c[100],l[100][100],e; int a[1000],b[1000],i,j,m,p,q; scanf("%lf",&n); m=0; for(i=0;i<n;i++) { scanf("%lf%lf%lf",&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])); c[m]=l[i][j]; a[m]=i; b[m]=j; m=m+1; } } for(p=0;p<m;p++) { for(q=0;q<(m-1-p);q++) { if(c[q]>c[q+1]) { e=c[q+1]; c[q+1]=c[q]; c[q]=e; e=a[q+1]; a[q+1]=a[q]; a[q]=e; e=b[q+1]; b[q+1]=b[q]; b[q]=e; } } } for(p=0;p<m;p++) { for(q=0;q<(m-1-p);q++) { if(c[q]==c[q+1]) { if(a[q]<a[q+1]||b[q]<b[q+1]) { e=a[q+1]; a[q+1]=a[q]; a[q]=e; e=b[q+1]; b[q+1]=b[q]; b[q]=e; } } } } for(i=m-1;i>=0;i--) { printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],c[i]); } return 0; }
64
31,505
int main() { struct sanD { int x; int y; int z; }room[10]; int n, i, j; double dis[100]; double temp; int x1[100], x2[100], y1[100], y2[100], z1[100], z2[100]; int k = 1; cin >> n; for(i = 0; i < n; i++) cin >> room[i].x >> room[i].y >> room[i].z; for(i = 0; i < n; i++) for(j = i + 1; j < n; j++) { x1[k] = room[i].x; y1[k] = room[i].y; z1[k] = room[i].z; x2[k] = room[j].x; y2[k] = room[j].y; z2[k] = room[j].z; dis[k] = sqrt((x1[k] - x2[k]) * (x1[k] - x2[k]) + (y1[k] - y2[k]) * (y1[k] - y2[k]) + (z1[k] - z2[k]) * (z1[k] - z2[k])); k++; } for(i = 1; i <= n * (n - 1) / 2; i++) { for(j = n * (n - 1) / 2; j >= 1 + i ; j--) { if(dis[j] > dis[j - 1]) { temp = dis[j - 1]; dis[j - 1] = dis[j]; dis[j] = temp; temp = x1[j - 1]; x1[j - 1] = x1[j]; x1[j] = temp; temp = x2[j - 1]; x2[j - 1] = x2[j]; x2[j] = temp; temp = y1[j - 1]; y1[j - 1] = y1[j]; y1[j] = temp; temp = y2[j - 1]; y2[j - 1] = y2[j]; y2[j] = temp; temp = z1[j - 1]; z1[j - 1] = z1[j]; z1[j] = temp; temp = z2[j - 1]; z2[j - 1] = z2[j]; z2[j] = temp; } } } for(i = 1; i <= n * (n - 1) / 2; i++) cout << "(" << x1[i] << "," << y1[i] << "," << z1[i] << ")-(" << x2[i] << "," << y2[i] << "," << z2[i] << ")=" << fixed << setprecision(2) << dis[i] << endl; return 0; }
64
31,506
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
31,507
int main() { int a[100],b[100],x[20],y[20],z[20]; double h[100]; double q; int i,j,k,n,t,p; cin >>n; for (i=1;i<=n;i++) cin >>x[i]>>y[i]>>z[i]; t=0; for (i=1;i<n;i++) for (j=i;j<=n;j++) if (i!=j) { t++; a[t]=i; b[t]=j; h[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;i++) for (j=1;j<t;j++) { if (h[j]<h[j+1]) {q=h[j]; h[j]=h[j+1]; h[j+1]=q; 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=1;i<=t;i++) { cout<<"("<<x[a[i]]<<","<<y[a[i]]<<","<<z[a[i]]<<")-("<<x[b[i]]<<","<<y[b[i]]<<","<<z[b[i]]<<")="; printf("%.2f",h[i]); cout<<endl; } return 0; }
64
31,508
struct distance { double d; int dx; int dy; }dis[100] = {0}, t; struct point { int x; int y; int z; }poi[10] = {0}; void input(int); void calculate(int); void arrange(int); void output(int); int main() { int n; cin >> n; input(n); calculate(n); arrange(n); output(n); return 0; } void input(int n) { int i; for(i = 0; i < n; i++) { cin >> poi[i].x >> poi[i].y >> poi[i].z; } } void calculate(int n) { int i; /* for(i = 0; i < n * n; i++) { dis[i].d = sqrt((poi[i/n].x - poi[i%n].x) * (poi[i/n].x - poi[i%n].x)+ (poi[i/n].y - poi[i%n].y) * (poi[i/n].y - poi[i%n].y)+ (poi[i/n].z - poi[i%n].z) * (poi[i/n].z - poi[i%n].z)); dis[i].dx = i / n; dis[i].dy = i % n; } */ int x1 = 0, y1 = 1; for(i = 0; i < n * (n - 1) / 2; i++) { dis[i].d = sqrt((poi[x1].x - poi[y1].x) * (poi[x1].x - poi[y1].x) + (poi[x1].y - poi[y1].y) * (poi[x1].y - poi[y1].y) + (poi[x1].z - poi[y1].z) * (poi[x1].z - poi[y1].z)); dis[i].dx = x1; dis[i].dy = y1; y1++; if(y1 == n) { x1++; y1 = x1 + 1; } } return; } void arrange(int n) { int i; int j; for(i = 0; i < n * (n - 1) / 2 - 1; i++) { for(j = 0; j < n * (n - 1) / 2 - i - 1; j++) { if(dis[j].d < dis[j + 1].d) { t = dis[j]; dis[j] = dis[j + 1]; dis[j + 1] = t; } } } return; } void output(int n) { int i; for(i = 0; i < n * (n - 1) / 2; i++) //(0,0,0)-(1,1,1)=1.73 { cout << "(" << poi[dis[i].dx].x << "," << poi[dis[i].dx].y << "," << poi[dis[i].dx].z << ")-(" << poi[dis[i].dy].x << "," << poi[dis[i].dy].y << "," << poi[dis[i].dy].z << ")=" << setprecision(2) << fixed <<dis[i].d << endl; } return; }
64
31,509
struct dis{ int p1[3]; int p2[3]; double d; }; void main() { int a[10][3],i,j,k,r,n; struct dis dt[45],t; scanf("%d",&n); for (i=0;i<n;i++) { for (j=0;j<3;j++) { scanf("%d",&a[i][j]); } } for (i=0,r=0;i<n;i++) { for (j=i+1;j<n;j++) { for (dt[r].d=0,k=0;k<3;k++) { dt[r].p1[k]=a[i][k]; dt[r].p2[k]=a[j][k]; dt[r].d+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]); } dt[r].d=sqrt(dt[r].d); r++; } } for (r=1;r<n*(n-1)/2;r++) { for (k=0;k<n*(n-1)/2-r;k++) { if (dt[k].d<=dt[k+1].d) { t=dt[k]; dt[k]=dt[k+1]; dt[k+1]=t; } } } for (i=r-1;dt[i].d==dt[i-1].d;i--); for (j=r-1;j>i;j--) { for (k=r-1;k>=i+r-j;k--) { t=dt[k]; dt[k]=dt[k-1]; dt[k-1]=t; } } for (i=0;i<r;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dt[i].p1[0],dt[i].p1[1],dt[i].p1[2],dt[i].p2[0],dt[i].p2[1],dt[i].p2[2],dt[i].d); } }
64
31,510
int main(){ int n,c=0; double j[100],k; scanf("%d",&n); int x[100],y[100],z[100],x1[100],y1[100],z1[100],x2[100],y2[100],z2[100]; for(int b=0;b<n;b++){ scanf("%d%d%d",&x[b],&y[b],&z[b]); } for(int p=0;p<n;p++){ for( int l=p+1;l<n;l++){ k=((x[p]-x[l])*(x[p]-x[l])+(y[p]-y[l])*(y[p]-y[l])+(z[p]-z[l])*(z[p]-z[l]))*1.0; j[c]=sqrt(k); x1[c]=x[p];y1[c]=y[p];z1[c]=z[p]; x2[c]=x[l];y2[c]=y[l];z2[c]=z[l]; c++; } } for(int a=1;a<=n*(n-1)/2;a++){ double e; for(int i=0;i<n*(n-1)/2-a;i++){ if(j[i]<j[i+1]){ e=j[i+1]; j[i+1]=j[i]; j[i]=e; int f; f=x1[i+1]; x1[i+1]=x1[i]; x1[i]=f; f=y1[i+1]; y1[i+1]=y1[i]; y1[i]=f; f=z1[i+1]; z1[i+1]=z1[i]; z1[i]=f; f=x2[i+1]; x2[i+1]=x2[i]; x2[i]=f; f=y2[i+1]; y2[i+1]=y2[i]; y2[i]=f; f=z2[i+1]; z2[i+1]=z2[i]; z2[i]=f; } } } for(int i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x1[i],y1[i],z1[i],x2[i],y2[i],z2[i],j[i]); } return 0; }
64
31,511
int main(){ int n,i,j,k=0,Nline,dx,dy,dz; scanf("%d",&n); //?????? struct Dot{ int x,y,z; } dots[n]; //????,???????? Nline=n*(n-1)/2; //??????(????????) for(i=0;i<n;i++) { scanf("%d %d %d",&dots[i].x,&dots[i].y,&dots[i].z); //?????? } struct Line{ int x1,y1,z1; int x2,y2,z2; float dist; } lines[Nline],temp; //???????????-??????????? for(i=0;i<n;i++){ //?????? for(j=(i+1);j<n;j++) { lines[k].x1=dots[i].x; lines[k].y1=dots[i].y; lines[k].z1=dots[i].z; lines[k].x2=dots[j].x; lines[k].y2=dots[j].y; lines[k].z2=dots[j].z; dx=lines[k].x1-lines[k].x2; dy=lines[k].y1-lines[k].y2; dz=lines[k].z1-lines[k].z2; lines[k].dist=sqrt(dx*dx+dy*dy+dz*dz); k++; } } for(i=0;i<Nline-1;i++)//??Nline? { for(j=0;j<Nline-i;j++) { if(lines[j].dist<lines[j+1].dist) { temp=lines[j]; lines[j]=lines[j+1]; lines[j+1]=temp; } } } for(i=0;i<Nline;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",lines[i].x1,lines[i].y1,lines[i].z1,lines[i].x2,lines[i].y2,lines[i].z2,lines[i].dist); // printf("%d",i); } return 0; }
64
31,512
void main() { int i,j,k,n; int point[10][3]; double dis[10][10]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d %d %d",&point[i][0],&point[i][1],&point[i][2]); // for(i=0;i<n;i++) // printf("%d %d %d\n",point[i][0],point[i][1],point[i][2]); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) dis[i][j]=(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]); for(k=n*(n-1)/2;k>0;k--) { double max=0; int s,t; for (i=0;i<n-1;i++) for(j=i+1;j<n;j++) if(dis[i][j]>max) { max=dis[i][j]; s=i; t=j; } max=sqrt(max); printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",point[s][0],point[s][1],point[s][2],point[t][0],point[t][1],point[t][2],max); dis[s][t]=0; } }
64
31,513
double sqrt(double x); int main(){ int n; int sz[10][3]; int f=0; double jl[100]; int zbx[100],zby[100]; scanf("%d",&n); for(int s=0;s<n;s++){ for(int c=0;c<3;c++){ scanf("%d",&sz[s][c]); } } for(int r=0;r<n;r++){ for(int t=r+1;t<n;t++){ jl[f]=sqrt(((sz[r][0]-sz[t][0])*(sz[r][0]-sz[t][0]))+((sz[r][1]-sz[t][1])*(sz[r][1]-sz[t][1]))+((sz[r][2]-sz[t][2])*(sz[r][2]-sz[t][2]))); zbx[f]=r; zby[f]=t; f++; } } for(int k=1;k<=f;k++){ int b,p; double e; for(int m=0;m<f-k;m++){ if(jl[m]<jl[m+1]){ e=jl[m];b=zbx[m];p=zby[m]; jl[m]=jl[m+1];zbx[m]=zbx[m+1];zby[m]=zby[m+1]; jl[m+1]=e;zbx[m+1]=b;zby[m+1]=p; } } } for(int q=0;q<f;q++){ printf("("); for(int l=0;l<2;l++){ printf("%d,",sz[zbx[q]][l]); } printf("%d)",sz[zbx[q]][2]); printf("-("); for(int h=0;h<2;h++){ printf("%d,",sz[zby[q]][h]); } printf("%d)=",sz[zby[q]][2]); printf("%.2lf\n",jl[q]); } return 0; }
64
31,514
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
31,515
int main(){ int n; scanf("%d",&n); int d[n][3]; for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ scanf("%d",&d[i][j]); } } int c=n*(n-1)/2; double len[c]; for(int i=0;i<c;i++){ len[i]=0; } int b=0; int o[c], p[c], q[c], r[c], s[c], t[c]; for(int i=0;i<(n-1);i++){ for(int j=i+1;j<n;j++){ double tmp=0; tmp=1.0*sqrt((d[i][0]-d[j][0])*(d[i][0]-d[j][0])+(d[i][1]-d[j][1])*(d[i][1]-d[j][1])+(d[i][2]-d[j][2])*(d[i][2]-d[j][2])); len[b]=tmp; o[b]=d[i][0]; p[b]=d[i][1]; q[b]=d[i][2]; r[b]=d[j][0]; s[b]=d[j][1]; t[b]=d[j][2]; b=b+1; } } for(int i=0;i<c;i++){ for(int j=c-1;j>i;j--){ if (len[j]>len[j-1]){ double tmp=0; tmp=len[j-1]; len[j-1]=len[j]; len[j]=tmp; int y=0; y=o[j-1]; o[j-1]=o[j]; o[j]=y; y=0; y=p[j-1]; p[j-1]=p[j]; p[j]=y; y=0; y=q[j-1]; q[j-1]=q[j]; q[j]=y; y=0; y=r[j-1]; r[j-1]=r[j]; r[j]=y; y=0; y=s[j-1]; s[j-1]=s[j]; s[j]=y; y=0; y=t[j-1]; t[j-1]=t[j]; t[j]=y; } } } for(int i=0;i<c;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",o[i], p[i], q[i], r[i], s[i], t[i], len[i]); } return 0; }
64
31,516
int main() { int n,i,e,j=1,k; int x[10]; int y[10]; int z[10]; double a[45],m; int b[45]; int c[45]; 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(k=i+1;k<=n;k++){ a[j]=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])); b[j]=i; c[j]=k; j++;}} j=j-1; for(k=1;k<=j-1;k++){ for(i=1;i<=j-k;i++){ if(a[i]<a[i+1]){ m=a[i];a[i]=a[i+1];a[i+1]=m; e=b[i];b[i]=b[i+1];b[i+1]=e; e=c[i];c[i]=c[i+1];c[i+1]=e; }}} for(k=1;k<=j;k++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[b[k]],y[b[k]],z[b[k]],x[c[k]],y[c[k]],z[c[k]],a[k]) ;} return 0; }
64
31,517
int main() { int i,k,m,n,h,d,g; int a[10],b[10],c[10],p[50],q[50]; double s[50],max; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d%d",&a[i],&b[i],&c[i]); } for(i=1,m=0;i<n;i++) { for(k=i+1;k<=n;k++) { m++; s[m]=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])); p[m]=i; q[m]=k; } } for(i=1;i<=m;i++) { for(k=1;k<=m-i;k++) { if(s[k]<s[k+1]) { max=s[k]; s[k]=s[k+1]; s[k+1]=max; h=p[k]; p[k]=p[k+1]; p[k+1]=h; d=q[k]; q[k]=q[k+1]; q[k+1]=d; } } } for(i=1;i<=m;i++) { h=p[i]; d=q[i]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[h],b[h],c[h],a[d],b[d],c[d],s[i]); } return 0; }
64
31,518
struct node { int x,y,z; }p[10]; struct d { double d; int p1,p2; }dis[45]; int n,t=0; double dist(int x,int y) { int dx=p[x].x-p[y].x,dy=p[x].y-p[y].y,dz=p[x].z-p[y].z; return sqrt(1.0*dx*dx+1.0*dy*dy+1.0*dz*dz); } void swap(int i,int j) { struct d tmp=dis[i]; dis[i]=dis[j]; dis[j]=tmp; } void init() { int i,j; 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;i++) { for(j=i+1;j<n;j++) { dis[t].p1=i;dis[t].p2=j; dis[t].d=dist(i,j); t++; } } } void solve() { int i,j; for(i=0;i<t;i++) { for(j=0;j<t-i-1;j++) { if(dis[j].d<dis[j+1].d) { swap(j,j+1); } } } } void print() { int i; for(i=0;i<t;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",p[dis[i].p1].x,p[dis[i].p1].y,p[dis[i].p1].z, p[dis[i].p2].x,p[dis[i].p2].y,p[dis[i].p2].z,dis[i].d); } } int main() { init(); solve(); print(); return 0; }
64
31,519
int main() { int n; scanf("%d",&n); double x[150],y[150],z[150]; int i; for(i=1;i<=n;i++) { scanf("%lf",&x[i]); scanf("%lf",&y[i]); scanf("%lf",&z[i]); } int j,h; h=1; double sum; double s1[150][150],s2[150][150]; double a[10000]; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { sum=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); s1[i][j]=sqrt(sum); s2[i][j]=s1[i][j]; a[h]=s1[i][j]; h++; } } h--; int k; double e; for(k=1;k<h;k++) { for(i=1;i<=h-k;i++) { if(a[i]<a[i+1]) { e=a[i]; a[i]=a[i+1]; a[i+1]=e; } } } int count=2; double b[10000]; b[1]=a[1]; for(i=2;i<=h;i++) { if(a[i]!=a[i-1]) { b[count]=a[i]; count++; } } count--; for(k=1;k<=count;k++) { for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { if(s1[i][j]==b[k]) printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],b[k]); } } } return 0; }
64
31,520
int main(){ int pointnum,groupnum,i,j,k; int point[10][3]={0}; cin>>pointnum; groupnum=pointnum*(pointnum-1)/2; for(i=0;i<pointnum;i++) for(j=0;j<3;j++) cin>>point[i][j]; int group[45][6]={0}; double result[45]; for(i=0;i<45;i++) result[i]=0; for(i=k=0;i<pointnum-1;i++) for(j=i+1;j<pointnum;j++) { group[k][0]=point[i][0]; group[k][1]=point[i][1]; group[k][2]=point[i][2]; group[k][3]=point[j][0]; group[k][4]=point[j][1]; group[k][5]=point[j][2]; result[k]=sqrt((double)(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])); k++; } double temp1; int temp[6]; for(i=0;i<groupnum-1;i++) for(j=0;j<groupnum-1-i;j++) if(result[j]<result[j+1]) { temp1=result[j]; result[j]=result[j+1]; result[j+1]=temp1; for(k=0;k<6;k++) temp[k]=group[j][k]; for(k=0;k<6;k++) group[j][k]=group[j+1][k]; for(k=0;k<6;k++) group[j+1][k]=temp[k]; } for(i=0;i<groupnum;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",group[i][0],group[i][1],group[i][2],group[i][3],group[i][4],group[i][5],result[i]); return 0; }
64
31,521
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
31,522
struct dian { int a; int b; int c; }zb[11]; int main() { int q,n,i,j,s=1,k1[50],k2[50],h1; double k[50]={0},h; cin>>n; for(i=1;i<=n;i++) { cin>>zb[i].a>>zb[i].b>>zb[i].c; } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { k[s]=sqrt((zb[i].a-zb[j].a)*(zb[i].a-zb[j].a)+(zb[i].b-zb[j].b)*(zb[i].b-zb[j].b)+(zb[i].c-zb[j].c)*(zb[i].c-zb[j].c)); k1[s]=i; k2[s]=j; s++; } } for(i=1;i<=n*(n-1)/2-1;i++) { for(j=1;j<=n*(n-1)/2-i;j++) { if(k[j]<k[j+1]) { h=k[j]; k[j]=k[j+1]; k[j+1]=h; h1=k1[j]; k1[j]=k1[j+1]; k1[j+1]=h1; h1=k2[j]; k2[j]=k2[j+1]; k2[j+1]=h1; } } } for(i=1;i<=n*(n-1)/2;i++) { cout<<"("<<zb[k1[i]].a<<","<<zb[k1[i]].b<<","<<zb[k1[i]].c<<")-("<<zb[k2[i]].a<<","<<zb[k2[i]].b<<","<<zb[k2[i]].c<<")="; printf("%.2f",k[i]); cout<<endl; } cin>>q; return 0; }
64
31,523
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
31,524
int main() { float a[32]={0},c[12][12]={0};//???????????i?????j???????? int i,j,m=0,n=0; cin>>n; for(i=1;i<=3*n;i++) cin>>a[i]; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { c[i][j]=sqrt((a[i*3-1]-a[j*3-1])*(a[i*3-1]-a[j*3-1])+(a[i*3-2]-a[j*3-2])*(a[i*3-2]-a[j*3-2])+(a[i*3]-a[j*3])*(a[i*3]-a[j*3]));//???? } } int e,f,z=0,y,g; y=n*(n-1)/2;//???????? for(g=y;g>=1;g--)//??????????? { for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { z=0; for(e=1;e<n;e++) { for(f=e+1;f<=n;f++) { if(c[i][j]>=c[e][f])//???? z=z+1; } } if(z==g) { cout<<"("<<a[i*3-2]<<","<<a[i*3-1]<<","<<a[i*3]<<")-("<<a[j*3-2]<<","<<a[j*3-1]<<","<<a[j*3]<<")="; printf("%0.2f", c[i][j]); cout<<endl; } } } } return 0; }
64
31,525
int main() { int n,a[10],b[10],c[10],i,j,k,m,h=0; double d[ROW][COL],e[100],w,f; scanf("%d",&n); for(i=0;i<n;i++){ if(i==0){ scanf("%d %d %d",&a[i],&b[i],&c[i]); }else{ scanf(" %d %d %d",&a[i],&b[i],&c[i]); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ w=1.0*((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); d[i][j]=pow(w,1.0/2); e[h]=d[i][j]; h++; } } m=n*(n-1)/2; for(k=1;k<=m;k++){ for(i=0;i<m-k;i++){ if(e[i]>e[i+1]){ f=e[i+1]; e[i+1]=e[i]; e[i]=f; } } } e[m]=0; for(k=m-1;k>=0;k--){ if(!(e[k]==e[k+1])){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(d[i][j]==e[k]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],a[j],b[j],c[j],e[k]); } } } } } return 0; }
64
31,526
int n[100][3]; int main() { int m,i,j,t,y[100][2]={0},l=0; double k[30][30]={0},max=0,x[30][30]={0}; cin>>m; for(i=0;i<m;i++) { for(j=0;j<3;j++) cin>>n[i][j]; } for(i=0;i<m;i++) { for(j=m-1;j>i;j--) { for(t=0;t<3;t++) { k[i][j]+=(n[i][t]-n[j][t])*(n[i][t]-n[j][t]); } k[i][j]=sqrt(k[i][j]); x[i][j]=k[i][j]; } } for(t=1;t<m;t++) { l=l+t; } for(t=0;t<l;t++) { max=0; for(i=0;i<m;i++) { for(j=i+1;j<m;j++) { if(x[i][j]>max) { max=x[i][j]; y[t][0]=i; y[t][1]=j; } } } x[y[t][0]][y[t][1]]=0; } for(t=0;t<l;t++) { cout<<'('<<n[y[t][0]][0]<<','<<n[y[t][0]][1]<<','<<n[y[t][0]][2]<<')'<<'-'<<'('<<n[y[t][1]][0]<<','<<n[y[t][1]][1]<<','<<n[y[t][1]][2]<<')'<<'='<<fixed<<setprecision(2)<<k[y[t][0]][y[t][1]]<<endl; } char dd; cin>>dd; return 0; }
64
31,527
int main(){ int n,i,j,x,e,k; int sz[10][3]={0}; double l[45][3]; double t; int d; scanf("%d",&n); for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&(sz[i][j])); } } for(x=0,i=0;i<n-1;i++){ for(e=i+1;e<n;e++,x++){ l[x][0]=sqrt(pow(sz[i][0]*1.0-sz[e][0]*1.0,2)+ pow(sz[i][1]*1.0-sz[e][1]*1.0,2)+ pow(sz[i][2]*1.0-sz[e][2]*1.0,2));//???? l[x][1]=i;//???????? l[x][2]=e; } } for( k = 1 ; k <= (n-1)*n/2 ; k++){ for( i = 0; i < (n-1)*n/2 - k; i++){ if(l[i][0] < l[i+1][0]){ t = l[i+1][0]; //exchange lenth l[i+1][0] = l[i][0]; l[i][0] = t; d= l[i+1][1]; //exchange point 1 l[i+1][1] = l[i][1]; l[i][1] = d; d = l[i+1][2]; //exchange point 2 l[i+1][2] = l[i][2]; l[i][2] = d; } } } for(e=0;e<(n-1)*n/2;e++){ i=l[e][1]; j=l[e][2]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[i][0],sz[i][1],sz[i][2], sz[j][0],sz[j][1],sz[j][2], l[e][0]); } return 0; }
64
31,528
int main(){ int a[10],b[10],c[10],e,f,g,l,m=0,o[50],p[50],q[50],r[50],s[50],t[50],u,v,w,x,y,z; double d[50],n; char h='(',i=')',j='-',k='='; scanf("%d",&e); for(f=0;f<e;f++){ scanf("%d%d%d",&a[f],&b[f],&c[f]); } for(f=0;f<(e-1);f++){ for(g=f+1;g<e;g++){ l=(a[f]-a[g])*(a[f]-a[g])+(b[f]-b[g])*(b[f]-b[g])+(c[f]-c[g])*(c[f]-c[g]); d[m]=sqrt(l); o[m]=a[f]; p[m]=b[f]; q[m]=c[f]; r[m]=a[g]; s[m]=b[g]; t[m]=c[g]; m++; } } for(f=0;f<m;f++){ for(g=f+1;g<m;g++){ if(d[f]<d[g]){ n=d[g]; u=o[g]; v=p[g]; w=q[g]; x=r[g]; y=s[g]; z=t[g]; for(e=g;e>f;e--){ d[e]=d[e-1]; o[e]=o[e-1]; p[e]=p[e-1]; q[e]=q[e-1]; r[e]=r[e-1]; s[e]=s[e-1]; t[e]=t[e-1]; } d[f]=n; o[f]=u; p[f]=v; q[f]=w; r[f]=x; s[f]=y; t[f]=z; } } } for(f=0;f<m;f++){ printf("%c%d,%d,%d%c%c%c%d,%d,%d%c%c%.2lf\n",h,o[f],p[f],q[f],i,j,h,r[f],s[f],t[f],i,k,d[f]); } return 0; }
64
31,529
int main(){ int i,j,l,k=0,n; cin >> n; double x[11],y[11],z[11],dis[11][11],temp[50],ins; 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++){ dis[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]); //?i???j???????? temp[k]=dis[i][j]; //?????????? k++; } } for(i=0;i<k;i++){ //????????? for(j=0;j<k-i-1;j++){ if(temp[j]>temp[j+1]){ ins=temp[j+1]; temp[j+1]=temp[j]; temp[j]=ins; } } } for(l=k-1;l>=0;l--){ //???? for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(dis[i][j]==temp[l]) { //???????????????? cout << fixed << setprecision(0)<<'(' << x[i]<<','<<y[i]<<','<<z[i]<<")-("<<x[j]<<','<<y[j]<<','<<z[j]<<")="<<fixed << setprecision(2)<<sqrt(temp[l])<<endl; //?????? dis[i][j]=-1; //??????????????????-1?????temp[]?? } } } } return 0; }
64
31,530
int main() { int M; M=N*(N-1)/2; int x[N],y[N],z[N],d[M],a[M],b[M],p=0,i,j,n,k,m; double c; scanf("%d",&n); printf("\n"); for(i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); printf("\n"); for(i=0;i<n;i++) for(j=i+1;j<n;j++) { d[p]=(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[p]=i; b[p]=j; p++; } for(j=1;j<=p;j++) for(i=0;i<p-j;i++) if(d[i]<d[i+1]) { d[i]=d[i]+d[i+1]; d[i+1]=d[i]-d[i+1]; d[i]=d[i]-d[i+1]; a[i]=a[i]+a[i+1]; a[i+1]=a[i]-a[i+1]; a[i]=a[i]-a[i+1]; b[i]=b[i]+b[i+1]; b[i+1]=b[i]-b[i+1]; b[i]=b[i]-b[i+1]; } for(i=0;i<p;i++) { k=a[i]; m=b[i]; c=sqrt(d[i]); printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[k],y[k],z[k],x[m],y[m],z[m],c); } return 0; }
64
31,531
//*********************************************************************** //??????? //??????? //?????? //*********************************************************************** int main() //??? { double s[45], l; //??double???????? //?????????????? int n, k = 0, m[90][3], l1, l2, l3, l4, l5,l6, c[10][3]; cin>>n; for(int i = 0; i < n; i++) //for?????? for(int j = 0; j < 3; j++) cin>>c[i][j]; for(int i = 0; i < n - 1; i++) //for????????? for(int j = i + 1; j < n; j++) { s[k] = sqrt(pow(c[i][0] - c[j][0],2.0) + pow(c[i][1] - c[j][1],2.0) +pow(c[i][2] - c[j][2],2.0)); m[k][0] = c[i][0]; m[k][1] = c[i][1]; m[k][2] = c[i][2]; m[k + n * (n - 1) / 2][0] = c[j][0]; m[k + n *(n - 1) / 2][1] = c[j][1]; m[k + n *(n - 1) / 2][2] = c[j][2]; k++; } for(int i = 1; i < k; i++) //for???? for(int j = 0; j < k - i; j++) { if(s[j] < s[j + 1]) { l = s[j]; l1 = m[j][0]; l2 = m[j][1]; l3 = m[j][2]; l4 = m[j + n * (n - 1) / 2][0]; l5 = m[j + n * (n - 1) / 2][1]; l6 = m[j + n * (n - 1) / 2][2]; s[j] = s[j + 1]; m[j][0] = m[j+1][0]; m[j][1] = m[j+1][1]; m[j][2] = m[j+1][2]; m[j + n * (n - 1) / 2][0] = m[j + n * (n - 1) / 2+1][0]; m[j + n * (n - 1) / 2][1] = m[j + n * (n - 1) / 2+1][1]; m[j + n * (n - 1) / 2][2] = m[j + n * (n - 1) / 2+1][2]; s[j + 1] = l; m[j + 1][0] = l1; m[j + 1][1] = l2; m[j + 1][2] = l3; m[j + n * (n - 1) / 2+1][0] = l4; m[j + n * (n - 1) / 2+1][1] = l5; m[j + n * (n - 1) / 2+1][2] = l6; } } for(int i = 0; i < k; i++) //for???? cout<<"("<<m[i][0]<<","<<m[i][1]<<","<<m[i][2]<<")-"<<"("<< m[i + n * (n - 1) / 2][0] <<","<< m[i + n * (n - 1) / 2][1]<<","<< m[i + n * (n - 1) / 2][2]<<")="<<fixed<<setprecision(2)<<s[i]<<endl; return 0; }
64
31,532
struct zuobiao { int x,y,z; }zuo[10]; struct dis { int left[3],right[3]; float d; }di[100],e; int main() { int l,n,ld,i,j; scanf("%d",&n); l=n*(n-1)/2; ld=0; for(i=0;i<n;i++) scanf("%d%d%d",&zuo[i].x,&zuo[i].y,&zuo[i].z); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { di[ld++].d=sqrt(pow(zuo[i].x-zuo[j].x,2)+pow(zuo[i].y-zuo[j].y,2)+pow(zuo[i].z-zuo[j].z,2)); di[ld-1].left[0]=zuo[i].x; di[ld-1].left[1]=zuo[i].y; di[ld-1].left[2]=zuo[i].z; di[ld-1].right[0]=zuo[j].x; di[ld-1].right[1]=zuo[j].y; di[ld-1].right[2]=zuo[j].z; } for(i=1;i<l;i++) for(j=0;j<l-i;j++) if(di[j].d<di[j+1].d) { e=di[j]; di[j]=di[j+1]; di[j+1]=e; } for(i=0;i<l;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",di[i].left[0],di[i].left[1],di[i].left[2],di[i].right[0],di[i].right[1],di[i].right[2],di[i].d); return 0; }
64
31,533
/* * fuck.cpp * * Created on: 2011-12-16 * Author: guan hong wei */ struct locations//????,???? { int x; int y; int z; }locations[100]; struct distances//????????? { int i; int j; double distance; }distances[100]; struct distances m; int main() { int n,i,j,t=0; cin>>n;//????? for(i=0;i<n;i++) { cin>>locations[i].x>>locations[i].y>>locations[i].z;//?????? } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { distances[t].i=i; distances[t].j=j; distances[t].distance=sqrt((double)(pow(locations[i].x-locations[j].x,2.0)+pow(locations[i].y-locations[j].y,2.0)+pow(locations[i].z-locations[j].z,2.0)));//???? t++; } } for(i=0;i<t;i++)//??????????? { for(j=t-1;j>i;j--) { if(distances[j].distance>distances[j-1].distance) { m=distances[j]; distances[j]=distances[j-1]; distances[j-1]=m; } } } for(i=0;i<t;i++) { cout<<'('<<locations[distances[i].i].x<<','<<locations[distances[i].i].y<<','<<locations[distances[i].i].z<<')'<<'-'<<'('<<locations[distances[i].j].x<<','<<locations[distances[i].j].y<<','<<locations[distances[i].j].z<<")="<<fixed<<setprecision(2)<<distances[i].distance<<endl; } return 0; }
64
31,534
/* *????SortTheDistance.cpp *????? *????: 2012-11-13 *????????????????????????????? */ int main(){ int x[15], y[15], z[15], left[50], right[50]; int n, i, j, k = 0, gn, temp1; double dis[50], temp; 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++) { left[k] = i; right[k] = j; dis[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++; } } gn = k; for (i = 0; i < gn; i++) { for (j = 0; j < gn - i - 1; j++) { if(dis[j + 1] > dis[j]) { temp = dis[j]; dis[j] = dis[j + 1]; dis[j + 1] = temp; temp1 = left[j]; left[j] = left[j + 1]; left[j + 1] = temp1; temp1 = right[j]; right[j] = right[j + 1]; right[j + 1] = temp1; } } } for (i = 0; i < gn; i++) { cout << "(" << x[left[i]] << "," << y[left[i]] << "," << z[left[i]] << ")-(" ; cout << x[right[i]] << "," << y[right[i]] << "," << z[right[i]] << ")=" << fixed << setprecision(2) << dis[i] << endl; } return 0; }
64
31,535
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
31,536
typedef struct Point { int x; int y; int z; }Point; double Distance(Point *p1,Point *p2) { int x=(p1->x)-(p2->x); int y=(p1->y)-(p2->y); int z=(p1->z)-(p2->z); double temp=(double)(x*x+y*y+z*z); return sqrt(temp); } void Input(Point *p[],int n) { int i; for(i=0;i<n;i++) { p[i]=(Point *)malloc(sizeof(Point)); scanf("%d",&p[i]->x); scanf("%d",&p[i]->y); scanf("%d",&p[i]->z); } } void Output(Point *p1,Point *p2) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n\n",p1->x,p1->y,p1->z,p2->x,p2->y,p2->z,Distance(p1,p2)); } int main() { int n,i,j; scanf("%d",&n); Point *p[10]; Input(p,n); double a[10*(10-1)/2]; int k=0; for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { int t=0; while(t<k+1 &&(a[t]-Distance(p[i],p[j])>0.00001 ||Distance(p[i],p[j])-a[t]>0.00001)) t++; if(t==k+1){ a[k]=Distance(p[i],p[j]); k++; } } } int count=k; for(i=0;i<count;i++) { for(j=i+1;j<count;j++) { if(a[i]<a[j]) { double temp=a[i]; a[i]=a[j]; a[j]=temp; } } } k=0; while(k<count) { for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { if(a[k]>Distance(p[i],p[j])) { if(a[k]-Distance(p[i],p[j])<0.000001) Output(p[i],p[j]); } else { if(Distance(p[i],p[j])-a[k]<0.000001) Output(p[i],p[j]); } } } k++; } }
64
31,537
int main(){ int n; int p[10][3],b[100],e[100]; int i,j,l; int x; double y; double d[100]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d ",&p[i][0],&p[i][1],&p[i][2]); } l=0; while(l<n*(n-1)/2){ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ d[l]=sqrt(1.0*((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]))); b[l]=i; e[l]=j; l++; } } } for(i=0;i<n*(n-1)/2-1;i++){ for(l=0;l<n*(n-1)/2-i;l++){ if(d[l]<d[l+1]){ y=d[l]; d[l]=d[l+1]; d[l+1]=y; x=b[l]; b[l]=b[l+1]; b[l+1]=x; x=e[l]; e[l]=e[l+1]; e[l+1]=x; } } } for(l=0;l<n*(n-1)/2;l++){ i=b[l]; j=e[l]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",p[(i)][0],(p[(i)][1]),(p[(i)][2]),(p[(j)][0]),(p[(j)][1]),(p[(j)][2]),d[l]); } return 0; }
64
31,538
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
31,539
//*************************** //*???????? * //*? ???? 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; }
64
31,540
/* * 80.cpp * ?????? * Created on: 2011-12-14 * ???????????n??????10??,??n?????????,??????????????????????????? */ int main() { int n,i,k,j,p,t=0; double q; cin>>n; struct zb { int x; int y; int z; }aa[n]; for(i=0;i<n;i++) { cin>>aa[i].x>>aa[i].y>>aa[i].z; } double s[n][n]; for(i=0;i<n;i++) { for(j=0;j<n;j++) { s[i][j]=0.0; } } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { s[i][j]=(sqrt)((aa[i].x-aa[j].x)*(aa[i].x-aa[j].x)+(aa[i].y-aa[j].y)*(aa[i].y-aa[j].y)+(aa[i].z-aa[j].z)*(aa[i].z-aa[j].z)); } } k=(n-1)*(n-1); double ss[k]; for(i=0;i<k;i++) { ss[i]=0.0; } for(i=0;i<n-1;i++) { for(j=1;j<n;j++) { ss[t]=s[i][j]; t=t+1; } } for(i=0;i<k;i++) { for(j=0;j<k-i-1;j++) { if(ss[j]<ss[j+1]) { q=ss[j+1]; ss[j+1]=ss[j]; ss[j]=q; } } } p=n*(n-1)/2; int a=0; for(t=0;t<p;t++) { for(i=0;i<n-1;i++) { for(j=1;j<n;j++) { if(ss[t]==s[i][j]) { cout<<"("<<aa[i].x<<","<<aa[i].y<<","<<aa[i].z<<")"<<"-"<<"("<<aa[j].x<<","<<aa[j].y<<","<<aa[j].z<<")"<<"="; cout<<fixed<<setprecision(2)<<s[i][j]<<endl; s[i][j]=-1.0; a=1; } } } } return 0; }
64
31,541
int main() { double s[10][3],a[100],b[100]; //?s????n????? double l[100]; int n; int i,j,k=0,g=0,c,d; double t; cin>>n; for(i=0;i<n;i++) for(j=0;j<3;j++) cin>>s[i][j]; for(i=0;i<n-1;i++) { for(g=i+1;g<n;g++) { l[k]=sqrt((s[i][0]-s[g][0])*(s[i][0]-s[g][0])+(s[i][1]-s[g][1])*(s[i][1]-s[g][1])+(s[i][2]-s[g][2])*(s[i][2]-s[g][2])); a[k]=i; b[k]=g; k++; } } k=k; //l????k???? for(i=0;i<k-1;i++) for(j=0;j<k-i;j++) { if(l[j]<l[j+1]) { t=l[j+1]; l[j+1]=l[j]; l[j]=t; //????? t=0; t=a[j+1]; a[j+1]=a[j]; a[j]=t; t=0; t=b[j+1]; b[j+1]=b[j]; b[j]=t; //??a?b?????l????? } } for(i=0;i<k;i++) { c=a[i]; d=b[i]; cout<<"("<<s[c][0]<<","<<s[c][1]<<","<<s[c][2]<<")-("<<s[d][0]<<","<<s[d][1]<<","<<s[d][2]<<")="; printf("%.2f",l[i]); if(i<k-1) cout<<endl; } return 0; }
64
31,542
int main() { int x[11],y[11],z[11],g=0,e1,e2; double d[11][11],m; int max[45][2]; int i,j,k,n,e,a,s; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&x[i]); scanf("%d",&y[i]); scanf("%d",&z[i]); } for(i=0;i<n;i++){ for(j=0;j<n;j++){ d[i][j]=0; } } for(i=0;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])); g=g+1; } } for(k=0;k<g;k++){ max[k][0]=0; max[k][1]=0; } for(k=0;k<g;k++){ s=k+1; for(a=0;a<n;a++){ s=s-n+a+1; if(s<=0){ s=s+n-a-1; break;} } max[k][0]=a; max[k][1]=s+a; } for(k=0;k<g;k++){ for(e=g-1;e>=k;e--){ if(e<g-1){ if(d[max[e][0]][max[e][1]]<d[max[e+1][0]][max[e+1][1]]){ e1=max[e][0]; max[e][0]=max[e+1][0]; max[e+1][0]=e1; e2=max[e][1]; max[e][1]=max[e+1][1]; max[e+1][1]=e2; } } } } for(k=0;k<g;k++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[max[k][0]],y[max[k][0]],z[max[k][0]],x[max[k][1]],y[max[k][1]],z[max[k][1]],d[max[k][0]][max[k][1]]); } return 0; }
64
31,543
int main() { int i, j, k = 0, x[10], y[10], z[10]; int n; struct distance { int x1; int y1; int z1; int x2; int y2; int z2; double d; }dis[100], t; cin >> n; for (i = 0; i < n; i++) { cin >> x[i]; cin >> y[i]; cin >> z[i]; } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { dis[k].x1 = x[i]; dis[k].y1 = y[i]; dis[k].z1 = z[i]; dis[k].x2 = x[j]; dis[k].y2 = y[j]; dis[k].z2 = z[j]; dis[k].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])); k++; } } for (i = 0; i < k - 1; i++) { for (j = 0; j < k - 1 - i; j++) { if (dis[j].d < dis[j + 1].d) { t = dis[j]; dis[j] = dis[j + 1]; dis[j + 1] = t; } } } for (i = 0; i < k; 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].d << endl; } return 0; }
64
31,544
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
31,545
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
31,546
struct distants {double d; int x; int y; }b[45],mid; int main() {int n,i,j,num=0; int a[10][3]; struct distants b[45],mid; scanf("%d",&n); if(n<=10){ 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[num].d=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]))); b[num].x=i; b[num].y=j; num++; } }//????num????b[num-1].d for(i=1;i<num;i++) { for(j=1;j<=num-i;j++) { if((b[j-1].d<b[j].d)||((b[j-1].d-b[j].d<1e-6)&&(b[j-1].x>b[j].x))||((b[j-1].d-b[j].d<1e-6)&&(b[j-1].x==b[j].x)&&(b[j-1].y>b[j].y))) { mid=b[j-1]; b[j-1]=b[j]; b[j]=mid; } } } for(i=0;i<num;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[b[i].x][0],a[b[i].x][1],a[b[i].x][2],a[b[i].y][0],a[b[i].y][1],a[b[i].y][2],b[i].d); } } return 0; }
64
31,547
struct point { int x; int y; int z; }po[10]; struct distance { double dist; int x1; int y1; int z1; int x2; int y2; int z2; }; int main() { int n,i,j,k=0; struct distance dis[50],temp; cin>>n; for(i=0;i<n;i++) { cin>>po[i].x>>po[i].y>>po[i].z; } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { dis[k].dist=sqrt((po[i].x-po[j].x)*(po[i].x-po[j].x)+(po[i].y-po[j].y)*(po[i].y-po[j].y)+(po[i].z-po[j].z)*(po[i].z-po[j].z)); dis[k].x1=po[i].x; dis[k].y1=po[i].y; dis[k].z1=po[i].z; dis[k].x2=po[j].x; dis[k].y2=po[j].y; dis[k].z2=po[j].z; k++; } for(i=0;i<n*(n-1)/2-1;i++) { for(j=0;j<n*(n-1)/2-i-1;j++) { if(dis[j].dist<dis[j+1].dist) { temp=dis[j+1]; dis[j+1]=dis[j]; dis[j]=temp; } } } for(i=0;i<n*(n-1)/2;i++) { cout<<"("<<dis[i].x1<<","<<dis[i].y1<<","<<dis[i].z1<<")"<<"-"<<"("<<dis[i].x2<<","<<dis[i].y2<<","<<dis[i].z2<<")"<<"="<<fixed<<setprecision(2)<<dis[i].dist<<endl; } return 0; }
64
31,548
int main(){ int n,i,m,j,k,w,p; int sz[1000][3],num[10000][2]; double d[1000],q; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&sz[i][0] ,&sz[i][1] ,&sz[i][2]); } m=n*(n-1)/2; k=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ d[k]=sqrt((double)((sz[i][0]-sz[j][0])*(sz[i][0]-sz[j][0])+(sz[i][1]-sz[j][1])*(sz[i][1]-sz[j][1])+(sz[i][2]-sz[j][2])*(sz[i][2]-sz[j][2]))); num[k][0]=i; num[k][1]=j; k++; } } for(j=1;j<=m;j++){ for(i=0;i<m-j;i++){ if(d[i]<d[i+1]){ q=d[i];d[i]=d[i+1];d[i+1]=q; w=num[i][0]; num[i][0]=num[i+1][0]; num[i+1][0]=w; p=num[i][1]; num[i][1]=num[i+1][1]; num[i+1][1]=p; } } } for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[num[i][0]][0],sz[num[i][0]][1],sz[num[i][0]][2],sz[num[i][1]][0],sz[num[i][1]][1],sz[num[i][1]][2],d[i]); } return 0; }
64
31,549
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
31,550
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
31,551
int main() { int n,i,k,m,p,t,zong; double ju; int a[100],b[100],c[100],xe[100],f[100],g[100],h[100],l[100],he[100]; double juli[100]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); } k=0; int x; for(m=0;m<n;m++){ for(p=m+1;p<n;p++){ x=(a[m]-a[p])*(a[m]-a[p])+(b[m]-b[p])*(b[m]-b[p])+(c[m]-c[p])*(c[m]-c[p]) ; juli[k]=sqrt(x); xe[k]=a[m]; f[k]=b[m]; g[k]=c[m]; h[k]=a[p]; l[k]=b[p]; he[k]=c[p]; k++; } } zong=n*(n-1)/2; for(i=0;i<zong;i++){ for(k=0;k<zong-i-1;k++){ if(juli[k]<juli[k+1]){ ju=juli[k]; juli[k]=juli[k+1]; juli[k+1]=ju; t=xe[k]; xe[k]=xe[k+1]; xe[k+1]=t; t=f[k]; f[k]=f[k+1]; f[k+1]=t; t=g[k]; g[k]=g[k+1]; g[k+1]=t; t=he[k]; he[k]=he[k+1]; he[k+1]=t; t=h[k]; h[k]=h[k+1]; h[k+1]=t; t=l[k]; l[k]=l[k+1]; l[k+1]=t; } } } for(i=0;i<zong;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",xe[i],f[i],g[i],h[i],l[i],he[i],juli[i]); } return 0; }
64
31,552
int main() { int n; int a[10][3]; int i,j; int b[100][2]; double s[100]; scanf("%d", &n); for(i=0;i<n;i++) { scanf("%d%d%d",&(a[i][0]), &(a[i][1]), &(a[i][2])); } int k=0; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { s[k] = 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[k][0] = i; b[k][1] = j; k++; } } for(i=1; i<k; i++) { for(j=0;j<k-i;j++) { if(s[j] < s[j+1]) { double t=s[j]; s[j]=s[j+1]; s[j+1]=t; int tt=b[j][0]; b[j][0]=b[j+1][0]; b[j+1][0]=tt; tt=b[j][1]; b[j][1]=b[j+1][1]; b[j+1][1]=tt; } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", a[b[i][0]][0], a[b[i][0]][1], a[b[i][0]][2], a[b[i][1]][0], a[b[i][1]][1], a[b[i][1]][2], s[i]); } return 0; }
64
31,553
double distance(int xa,int ya,int za,int xb,int yb,int zb); double distance(int xa,int ya,int za,int xb,int yb,int zb){ int sum; double dis; sum=(xb-xa)*(xb-xa)+(yb-ya)*(yb-ya)+(zb-za)*(zb-za); dis=sqrt(sum); return dis; } int main(){ int n,i,t,j,b=0,w=0,te; double td; scanf("%d",&n); struct point{ int x,y,z; }point[10]; for(i=0;i<n;i++) scanf("%d %d %d",&point[i].x,&point[i].y,&point[i].z); struct{ int p,q; double dist; }temp[45]; for(i=0;i<45;i++) temp[i].dist=-1; for(i=0;i<n;i++) for(j=0;j<i;j++){ temp[w].p=i; temp[w].q=j; temp[w].dist=distance(point[i].x,point[i].y,point[i].z,point[j].x,point[j].y,point[j].z); w=w+1; } for(i=0;i<45;i++) for(w=0;w<44;w++) if(temp[w].dist<temp[w+1].dist) { te=temp[w+1].p; temp[w+1].p=temp[w].p; temp[w].p=te; te=temp[w+1].q; temp[w+1].q=temp[w].q; temp[w].q=te; td=temp[w+1].dist; temp[w+1].dist=temp[w].dist; temp[w].dist=td; } for(w=0;w<45;w++) if(temp[w].dist!=-1){ printf("(%d,%d,%d)-",point[temp[w].q].x,point[temp[w].q].y,point[temp[w].q].z); printf("(%d,%d,%d)=",point[temp[w].p].x,point[temp[w].p].y,point[temp[w].p].z); printf("%.2lf\n",temp[w].dist); } return 0; }
64
31,554
double f(int a[3], int b[3]); int main(){ int n,zb[M][3],dw[N][2],i,k; double jl[N]; scanf("%d",&n); for(i=0;i<n;i++){ for(k=0;k<3;k++){ scanf("%d",&zb[i][k]); } } int count=0; for(i=0;i<n-1;i++){ for(k=i+1;k<n;k++){ jl[count]=f(zb[i],zb[k]); dw[count][0]=i; dw[count][1]=k; count++; } } double e0; int e; for(k=1;k<count;k++){ for(i=0;i<count-k;i++){ if(jl[i]<jl[i+1]){ e0=jl[i]; jl[i]=jl[i+1]; jl[i+1]=e0; e=dw[i][0]; dw[i][0]=dw[i+1][0]; dw[i+1][0]=e; e=dw[i][1]; dw[i][1]=dw[i+1][1]; dw[i+1][1]=e; } } } int x,y; for(i=0;i<count;i++){ x=dw[i][0]; y=dw[i][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",zb[x][0], zb[x][1],zb[x][2],zb[y][0],zb[y][1],zb[y][2],jl[i]); } return 0; } double f(int a[3], int b[3]){ int sum,c; double result; sum=0; c=a[0]-b[0]; sum+=c*c; c=a[1]-b[1]; sum+=c*c; c=a[2]-b[2]; sum+=c*c; result=sqrt(sum); return result; }
64
31,555
int main() { int a[110][3],n,k,i,j,s=0,flag[1000][2],temp2; float b[110],temp1; double 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;i++) for(k=i+1;k<n;k++) { m=0; for(j=0;j<3;j++) m+=(a[k][j]-a[i][j])*(a[k][j]-a[i][j]); b[s]=sqrt(m); flag[s][0]=i; flag[s][1]=k; s++; } for(j=0;j<s-1;j++) for(i=0;i<s-j-1;i++) if(b[i]<b[i+1]) { temp1=b[i]; b[i]=b[i+1]; b[i+1]=temp1; for(k=0;k<2;k++) { temp2=flag[i][k]; flag[i][k]=flag[i+1][k]; flag[i+1][k]=temp2; } } for(i=0;i<s;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[flag[i][0]][0],a[flag[i][0]][1],a[flag[i][0]][2],a[flag[i][1]][0],a[flag[i][1]][1],a[flag[i][1]][2],b[i]); return 0; }
64
31,556
int main(){ int x[10],y[10],z[10],n,num=0;//????x,y,z?num????? double a[10][10],b[45];//??????????????????????????????????????? cin>>n; for(int i=0;i<n;i++){ cin>>x[i]>>y[i]>>z[i]; }//???????? for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ a[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])); b[num]=a[i][j]; num++; }//????????????????????? } double p; for(int i=0;i<num-1;i++){ for(int j=0;j<num-1-i;j++){ if(b[j]<b[j+1]){ p=b[j]; b[j]=b[j+1]; b[j+1]=p; } } }//????????????? for(int k=0;k<num;k++){ if(b[k]==b[k+1])continue;//?????????????????? else { for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(a[i][j]==b[k]){//????????????????? cout<<"("<<x[i]<<","<<y[i]<<","<<z[i]<<")"<<"-"<<"("<<x[j]<<","<<y[j]<<","<<z[j]<<")="; printf("%.2lf",b[k]);//?????? cout<<'\n'; } } } } } return 0; }
64
31,557
void main() { int num,r,s,t,q2,a[200],b[200]; double x[20],y[20],z[20],result[200],q1; scanf("%d",&num); for(r=0;r<num;r++) scanf("%lf%lf%lf",&x[r],&y[r],&z[r]); for(r=0,t=0;r<num-1;r++){ for(s=r+1;s<num;s++){ result[t]=sqrt((x[r]-x[s])*(x[r]-x[s])+(y[r]-y[s])*(y[r]-y[s])+(z[r]-z[s])*(z[r]-z[s])); a[t]=r;b[t]=s; t++; } } for(r=0;r<num*(num-1)/2-1;r++){ for(s=num*(num-1)/2-1;s>r;s--){ if(result[s-1]<result[s]){q1=result[s-1];result[s-1]=result[s];result[s]=q1; q2=a[s-1];a[s-1]=a[s];a[s]=q2;q2=b[s-1];b[s-1]=b[s];b[s]=q2;} } } for(r=0;r<num*(num-1)/2;r++) printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",x[a[r]],y[a[r]],z[a[r]],x[b[r]],y[b[r]],z[b[r]],result[r]); }
64
31,558
struct zuobiao { int x; int y; int z; }; struct zuhe { struct zuobiao dian1; struct zuobiao dian2; double s; }; double juli(int x3,int y3,int z3,int x4,int y4,int z4) { double d; d=(x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)+(z4-z3)*(z4-z3); d=sqrt(d); return d; } int main() { struct zuobiao dian[20]; struct zuhe zu[100]; struct zuhe c; int n,m,i,j,k=0; double l; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&dian[i].x,&dian[i].y,&dian[i].z); } m=n*(n-1)/2; for(i=0;i<m;i++) { for(j=i+1;j<n;j++) { l=juli(dian[i].x,dian[i].y,dian[i].z,dian[j].x,dian[j].y,dian[j].z); zu[k].dian1=dian[i]; zu[k].dian2=dian[j]; zu[k].s=l; k++; } } for(i=1;i<m;i++) { for(j=0;j<m-1;j++) { if(zu[j].s<zu[j+1].s) { c=zu[j]; zu[j]=zu[j+1]; zu[j+1]=c; } } } for(i=0;i<m;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",zu[i].dian1.x,zu[i].dian1.y,zu[i].dian1.z,zu[i].dian2.x,zu[i].dian2.y,zu[i].dian2.z,zu[i].s); } }
64
31,559
double juli(int a,int b,int c,int d,int e,int f); int main(){ int x[10],y[10],z[10]; int x1[1000],y1[1000],z1[1000],x2[1000],y2[1000],z2[1000]; int n,p=0; double ju[1000]; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&x[i]); scanf("%d",&y[i]); scanf("%d",&z[i]); } for(int a=0;a<100;a++){ for(int b=a+1;b<n;b++){ ju[p]=juli(x[a],y[a],z[a],x[b],y[b],z[b]); x1[p]=x[a]; y1[p]=y[a]; z1[p]=z[a]; x2[p]=x[b]; y2[p]=y[b]; z2[p]=z[b]; p++; } } for(int k=1;k<=p-1;k++){ double e; int o; for(int i=0;i<=p-1-k;i++){ if(ju[i]<ju[i+1]){ e=ju[i+1]; ju[i+1]=ju[i]; ju[i]=e; o=x1[i+1]; x1[i+1]=x1[i]; x1[i]=o; o=y1[i+1]; y1[i+1]=y1[i]; y1[i]=o; o=z1[i+1]; z1[i+1]=z1[i]; z1[i]=o; o=x2[i+1]; x2[i+1]=x2[i]; x2[i]=o; o=y2[i+1]; y2[i+1]=y2[i]; y2[i]=o; o=z2[i+1]; z2[i+1]=z2[i]; z2[i]=o; } } } for(int q=0;q<p;q++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x1[q],y1[q],z1[q],x2[q],y2[q],z2[q],ju[q]); } return 0; } double juli(int a,int b,int c,int d,int e,int f){ double result; double l,m,n; l=1.0*(d-a)*(d-a); m=1.0*(e-b)*(e-b); n=1.0*(f-c)*(f-c); result=sqrt(l+m+n); return result; }
64
31,560
//******************************** //*?????(14-4) ???? ** //*?????? 1300012887 ** //*???2013.12.11 ** //******************************** int main() { int n, i, j, k = 0; cin >> n; //???? struct dian //?????dian { int x; int y; int z; } a[12]; //???????a for (i = 0; i < n; i++) cin >> a[i].x >> a[i].y >> a[i].z; //??????? struct cha //?????cha { int x1; int y1; int z1; int x2; int y2; int z2; double c; } b[46], t; //???????b,???t for (i = 0; i < n-1; i++) //??????????? for (j = i+1; j < n; j++) { b[k].x1 = a[i].x; b[k].y1 = a[i].y; b[k].z1 = a[i].z; b[k].x2 = a[j].x; b[k].y2 = a[j].y; b[k].z2 = a[j].z; //??? b[k].c = sqrt((b[k].x2 - b[k].x1) * (b[k].x2 - b[k].x1) + (b[k].y2 - b[k].y1) * (b[k].y2 - b[k].y1) + (b[k].z2 - b[k].z1) * (b[k].z2 - b[k].z1)); //?????? k++; //?? } for (i = 0; i < k-1; i++) //???????????? for (j = 0; j < k-i-1; j++) { if (b[j].c < b[j+1].c) { t = b[j]; b[j] = b[j+1]; b[j+1] = t; } } for (i = 0; i < k; i++) //?????? { cout << "(" << b[i].x1 << "," << b[i].y1 << "," << b[i].z1 << ")" << "-" << "(" << b[i].x2 << "," << b[i].y2 << "," << b[i].z2 << ")" << "=" ; cout << fixed << setprecision(2) << b[i].c << endl; } return 0; }
64
31,561
struct DOT { int x,y,z; }dot[10],temp; int main() { int i,n,j,t,p,q; double d[10][10]={0},max; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&dot[i].x,&dot[i].y,&dot[i].z); }//printf("%d %d %d\n",dot[0].x,dot[0].y,dot[0].z); for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ d[i][j]=sqrt((dot[i].x-dot[j].x)*(dot[i].x-dot[j].x)+(dot[i].y-dot[j].y)*(dot[i].y-dot[j].y)+(dot[i].z-dot[j].z)*(dot[i].z-dot[j].z)); } } for(t=0;t<n*(n-1)/2;t++){max=d[0][0]; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(d[i][j]>max) {max=d[i][j];p=i;q=j;} } }//printf("%.2f",max); printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dot[p].x,dot[p].y,dot[p].z,dot[q].x,dot[q].y,dot[q].z,max); d[p][q]=0;} return 0; }
64
31,562
struct dian { int z[6]; double d; }; double ju(int x[3],int y[3]) { double d; d=sqrt((x[0]-y[0])*(x[0]-y[0])+(x[1]-y[1])*(x[1]-y[1])+(x[2]-y[2])*(x[2]-y[2])); return d; } int main() { int n,i,j,a[20][3],x=0; struct dian num[50]; 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++) { num[x].z[0]=a[i][0]; num[x].z[1]=a[i][1]; num[x].z[2]=a[i][2]; num[x].z[3]=a[j][0]; num[x].z[4]=a[j][1]; num[x].z[5]=a[j][2]; num[x].d=ju(a[i],a[j]); x++; } } n=n*(n-1)/2; for(i=0;i<n-1;i++) { for(j=0;j<n-i-1;j++) { if(num[j].d<num[j+1].d) { num[49]=num[j+1]; num[j+1]=num[j]; num[j]=num[49]; } } } for(i=0;i<n;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",num[i].z[0],num[i].z[1],num[i].z[2],num[i].z[3],num[i].z[4],num[i].z[5],num[i].d); } return 0; }
64
31,563
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
31,564
int main(){ int i,j,m=0,n,x[10],y[10],z[10],a,b,c,e,f,g,x1[55],y1[55],z1[55],x2[55],y2[55],z2[55]; double jl[55],d; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(i=0;i<n-1;i++){ for(j=i+1; j<n; j++){ jl[m]=sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2)+pow(z[i]-z[j],2)); x1[m]=x[i];x2[m]=x[j];y1[m]=y[i];y2[m]=y[j];z1[m]=z[i];z2[m]=z[j]; m++; } } for(j=0;j<m-1;j++){ for(i=0;i<m-j-1;i++){ if(jl[i]<jl[i+1]){ d=jl[i+1];jl[i+1]=jl[i];jl[i]=d; a=x1[i+1];x1[i+1]=x1[i];x1[i]=a; b=x2[i+1];x2[i+1]=x2[i];x2[i]=b; c=y1[i+1];y1[i+1]=y1[i];y1[i]=c; e=y2[i+1];y2[i+1]=y2[i];y2[i]=e; f=z1[i+1];z1[i+1]=z1[i];z1[i]=f; g=z2[i+1];z2[i+1]=z2[i];z2[i]=g; } } } 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],jl[i]); } return 0; }
64
31,565
/* * 1.cpp * * Created on: 2010-12-29 * Author: 10033 */ int main(){//???? int n,i,j; int a[10],b[10],c[10];//?? struct zuobiao{//??????????? int x[2]; int y[2]; int z[2]; float length; }number[100],t; cin>>n; for(i=0;i<n;i++)//?? cin>>a[i]>>b[i]>>c[i]; for(i=0;i<n;i++)//????zuobiao??? for(j=i+1;j<n;j++){ number[(((n-1)+(n-i))*i/2)+j-i].x[0]=a[i]; number[(((n-1)+(n-i))*i/2)+j-i].x[1]=a[j]; number[(((n-1)+(n-i))*i/2)+j-i].y[0]=b[i]; number[(((n-1)+(n-i))*i/2)+j-i].y[1]=b[j]; number[(((n-1)+(n-i))*i/2)+j-i].z[0]=c[i]; number[(((n-1)+(n-i))*i/2)+j-i].z[1]=c[j]; number[(((n-1)+(n-i))*i/2)+j-i].length=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=1;i<=(n-1)*n/2;i++)//???? for(j=1;j<=(n-1)*n/2-i;j++) if(number[j].length<number[j+1].length){ t=number[j]; number[j]=number[j+1]; number[j+1]=t; } for(i=1;i<=(n-1)*n/2;i++)//?? cout<<"("<<number[i].x[0]<<","<<number[i].y[0]<<","<<number[i].z[0]<<")-(" <<number[i].x[1]<<","<<number[i].y[1]<<","<<number[i].z[1]<<")="<<fixed<<setprecision(2)<<number[i].length<<endl; return 0; }//????
64
31,566
/* * 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
31,567
//???? int main() { double a[11],b[11],c[11]; int n,i,j,k,p,q; double max,dis[10][11]; cin>>n; for (i=1;i<=n;i++)//?? { cin>>a[i]>>b[i]>>c[i]; } for (i=1;i<n;i++)//?? { for (j=i+1;j<=n;j++) { dis[i][j]=(double)pow((double)pow(a[i]-a[j],2)+(double)pow(b[i]-b[j],2)+(double)pow(c[i]-c[j],2),0.5); if (dis[i][j]<0) { dis[i][j]=-dis[i][j]; } } } for (k=1;k<=n*(n-1)/2;k++)//????????? { max=dis[1][2]; p=1; q=2; for (i=1;i<n;i++) { for (j=i+1;j<=n;j++) { if (dis[i][j]>max) { max=dis[i][j]; p=i; q=j; } } } cout<<'('<<(int)a[p]<<','<<(int)b[p]<<','<<(int)c[p]<<')'<<'-'<<'('<<(int)a[q]<<','<<(int)b[q]<<','<<(int)c[q]<<')'<<'='<<fixed<<setprecision(2)<<dis[p][q]<<endl; dis[p][q]=0; } return 0; }
64
31,568
int main() { int spot[100][3],n,i,j,k=0; struct D { int s[2][3]; double d; } D[1000],tem; scanf("%d",&n); for (i=0;i<n;i++) scanf("%d%d%d",&spot[i][0],&spot[i][1],&spot[i][2]); for (i=0;i<n-1;i++) { for (j=i+1;j<n;j++) { D[k].s[0][0]=spot[i][0]; D[k].s[0][1]=spot[i][1]; D[k].s[0][2]=spot[i][2]; D[k].s[1][0]=spot[j][0]; D[k].s[1][1]=spot[j][1]; D[k].s[1][2]=spot[j][2]; D[k].d=(double)sqrt((spot[i][0]-spot[j][0])*(spot[i][0]-spot[j][0])+(spot[i][1]-spot[j][1])*(spot[i][1]-spot[j][1])+(spot[i][2]-spot[j][2])*(spot[i][2]-spot[j][2])); k++; } } for(i=0;i<k;i++) for(j=k-1;j>i;j--) { if (D[j].d>D[j-1].d) { tem=D[j]; D[j]=D[j-1]; D[j-1]=tem; } } for (i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",D[i].s[0][0],D[i].s[0][1],D[i].s[0][2],D[i].s[1][0],D[i].s[1][1],D[i].s[1][2],D[i].d); }
64
31,569
int main() { int x[10]; int y[10]; int z[10]; int a,b,c,n,i,r,j,p=0,k; double jl[45]; double d; scanf("%d",&n); k=n*(n-1)/2; for(i=0;i<n;i++){ scanf("%d",&x[i]); scanf("%d",&y[i]); scanf("%d",&z[i]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=x[i]-x[j]; b=y[i]-y[j]; c=z[i]-z[j]; jl[p]=sqrt(1.0*a*a+b*b+c*c); p++; } } double e; for(i=1;i<=k;i++){ for(j=0;j<k-i;j++){ if(jl[j]>jl[j+1]){ e=jl[j+1]; jl[j+1]=jl[j]; jl[j]=e; } } } double bcjl[45]; bcjl[0]=jl[0]; int w; w=1; for(i=1;i<k;i++){ if(jl[i]==jl[i-1]){ continue; }else{ bcjl[w]=jl[i]; w++; } } for(r=w-1;r>=0;r--){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=x[i]-x[j]; b=y[i]-y[j]; c=z[i]-z[j]; d=sqrt(1.0*a*a+b*b+c*c); if(d==bcjl[r]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],d); } } } } return 0; }
64
31,570
int main(){ int n,i,j,k,t; int x[101],y[101],z[101],a[46],b[46]; double d[46],t1; scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); k=0; for (i=1;i<=n-1;i++) for (j=i+1;j<=n;j++){ k=k+1; 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])); a[k]=i; b[k]=j; } for (i=1;i<=k;i++) for (j=1;j<=k-i;j++) if (d[j]<d[j+1]) { t1=d[j]; d[j]=d[j+1]; d[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; } for (i=1;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,571
int main() { int n, i, j; int location[11][3]; int (*p)[3]; cin >> n; for ( i = 1; i <= n; i++ ) { for ( j = 0; j < 3; j++ ) { cin >> location[i][j]; } } struct team { int a1; int a2; double distance; } zu[45], t; int k = 0; p = location; for ( i = 1; i < n; i++ ) { for ( j = i + 1; j <= n; j++ ) { zu[k].a1 = i; zu[k].a2 = j; int x, y, z; x = location[i][0] - location[j][0]; y = location[i][1] - location[j][1]; z = location[i][2] - location[j][2]; zu[k].distance = sqrt ( x * x + y * y + z * z ); k++; } } for ( i = 0; i < k - 1; i++ ) { for ( j = i + 1; j < k; j++ ) { if ( zu[i].distance - zu[j].distance < -0.01 ) { t = zu[i]; zu[i] = zu[j]; zu[j] = t; } else if ( fabs( zu[i].distance - zu[j].distance ) < 0.01 ) { if ( zu[i].a1 > zu[j].a1 ) { t = zu[i]; zu[i] = zu[j]; zu[j] = t; } else if ( zu[i].a1 == zu[j].a1 ) { if ( zu[i].a2 > zu[j].a2 ) { t = zu[i]; zu[i] = zu[j]; zu[j] = t; } } } } } for ( i = 0; i < k; i++ ) { cout << "(" << location[zu[i].a1][0] << "," << location[zu[i].a1][1] << "," << location[zu[i].a1][2] << ")-(" << location[zu[i].a2][0] << "," << location[zu[i].a2][1] << "," << location[zu[i].a2][2] << ")=" << fixed << setprecision(2) << zu[i].distance << endl; } return 0; }
64
31,572
int main(){ int a[10][3]; int n; int i,j,k; //double ans[100]; double ans[10][10]; 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){ ans[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)); //cout<<ans[i *n + j]<<" "; } //cout<<endl; } int sum = n*(n-1)/2; while(sum >0){ sum--; int maxI = 0; int maxJ = 1; for(i = 0;i<n;++i){ for(j = i+1;j<n;++j){ if(ans[i][j] > ans[maxI][maxJ]){ maxI = i; maxJ = j; } } } //(1,1,0)-(1,1,1)=1.00 cout<<"("<<a[maxI][0]<<","<<a[maxI][1]<<","<<a[maxI][2]<<")-(" <<a[maxJ][0]<<","<<a[maxJ][1]<<","<<a[maxJ][2]<<")=" <<fixed<<setprecision(2)<<ans[maxI][maxJ]<<endl; ans[maxI][maxJ] = -9999999; } cin>>i; return 0; }
64
31,573
int main() { struct { float first; float second;float distance; }b[100],temp; float a[11][3]; int p,q,n,k=0,i,j; 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].first=i; b[k].second=j; b[k].distance=sqrt(fabs(pow((a[i][0]-a[j][0]),2)+pow((a[i][1]-a[j][1]),2)+pow((a[i][2]-a[j][2]),2))); k++; } } for(i=0;i<n*(n-1)/2-1;i++) { for(j=n*(n-1)/2-1;j>i;j--) { if(b[j].distance>b[j-1].distance) { temp=b[j];b[j]=b[j-1];b[j-1]=temp; } } } for(i=0;i<n*(n-1)/2;i++) { p=b[i].first; q=b[i].second; cout<<"("<<a[p][0]<<","<<a[p][1]<<","<<a[p][2]<<")-("<<a[q][0]<<","<<a[q][1]<<","<<a[q][2]<<")="<<fixed<<setprecision(2)<<b[i].distance<<fixed<<setprecision(0)<<endl; } return 0; }
64
31,574
int main() { int n, i, j, k = 0, t, x[10], y[10], z[10]; double dis[10][9] = {0}, dist[50] = {0}, a; 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++) { dis[i][j-i-1] = 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])); dist[k++] = dis[i][j-i-1]; } } for (k = 0; k < n * (n - 1) / 2; k++) { for (t = 0; t < n * (n - 1) / 2 - k - 1; t++) { if (dist[t] < dist[t + 1]) { a = dist[t]; dist[t] = dist[t + 1]; dist[t + 1] = a; } } } for (k = 0; k < n * (n - 1) / 2; k++) { if (k >= 1 && dist[k] == dist[k - 1]) continue; for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (dis[i][j-i-1] == dist[k]) { cout<<'('<<x[i]<<','<<y[i]<<','<<z[i]<<')'<<'-'<<'('<<x[j]<<','<<y[j]<<','<<z[j]<<')' <<'='<<fixed<<setprecision(2)<<dist[k]<<endl; } } } } return 0; }
64
31,575
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
31,576
int main() { struct dot1 { int x; int y; int z; } dot[10]; float dis[10][10]={0,0}; float distance; int row, col, sign=0; int n, i, j; scanf("%d", &n); for (i=0;i<n;i++) { scanf("%d%d%d", &dot[i].x, &dot[i].y, &dot[i].z); } for (i=0;i<n;i++) { for(j=i+1;j<n;j++) { dis[i][j]=(float)(dot[i].x-dot[j].x)*(float)(dot[i].x-dot[j].x)+(float)(dot[i].y-dot[j].y)*(float)(dot[i].y-dot[j].y)+(float)(dot[i].z-dot[j].z)*(float)(dot[i].z-dot[j].z); dis[i][j]=sqrt((float)dis[i][j]); } } do { distance=dis[0][1]; row=0; col=1; for(i=0;i<n;i++) { for (j=i+1;j<n;j++) { if (distance<dis[i][j]) { distance=dis[i][j]; row=i; col=j; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", dot[row].x, dot[row].y, dot[row].z, dot[col].x, dot[col].y, dot[col].z, distance); dis[row][col]=0; sign+=1; } while(sign!=(n-1)*n/2); return 0; }
64
31,577
int main() { int n; cin >> n; int point[10][3] = {0}; // to store the position of the points float distance[45][3] = {0}; // to store the distances for(int i = 0; i < n; i++) for(int j = 0; j < 3; j++) cin >> point[i][j]; int count = 0; // to calculate the number of the distances for(int i = 0; i < n - 1; i++) for(int j = i + 1; j < n; j++) { // to calculate the distances and store the name of the points distance[count][0] = i; distance[count][1] = j; distance[count][2] = sqrt((float)(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])); count++; } float temp = 0; for(int i = 0; i < count - 1; i++) // bubble sort for(int j = i + 1; j < count ; j++) { if(distance[i][2] < distance[j][2]) { temp = distance[i][0]; distance[i][0] = distance[j][0]; distance[j][0] = temp; temp = distance[i][1]; distance[i][1] = distance[j][1]; distance[j][1] = temp; temp = distance[i][2]; distance[i][2] = distance[j][2]; distance[j][2] = temp; } else if(distance[i][2] == distance[j][2]) { if(distance[i][0] > distance[j][0]) { temp = distance[i][0]; distance[i][0] = distance[j][0]; distance[j][0] = temp; temp = distance[i][1]; distance[i][1] = distance[j][1]; distance[j][1] = temp; temp = distance[i][2]; distance[i][2] = distance[j][2]; distance[j][2] = temp; } if(distance[i][1] > distance[j][1]) { temp = distance[i][0]; distance[i][0] = distance[j][0]; distance[j][0] = temp; temp = distance[i][1]; distance[i][1] = distance[j][1]; distance[j][1] = temp; temp = distance[i][2]; distance[i][2] = distance[j][2]; distance[j][2] = temp; } } } for(int i = 0; i < count; i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", point[(int)distance[i][0]][0],point[(int)distance[i][0]][1],point[(int)distance[i][0]][2],point[(int)distance[i][1]][0],point[(int)distance[i][1]][1],point[(int)distance[i][1]][2],distance[i][2]); } return 0; }
64
31,578
int main() { int sz1[10][3],n,i=0,m; double d[100],e; scanf("%d", &n); m=n*(n-1)/2; for (int row=0; row<n; row++){ for (int col=0; col<3; col++){ scanf("%d", &sz1[row][col]); } } for (int row1=0; row1<n; row1++){ for (int row2=row1+1; row2<n; row2++){ d[i]=sqrt((pow(sz1[row1][0]-sz1[row2][0],2)+pow(sz1[row1][1]-sz1[row2][1],2)+pow(sz1[row1][2]-sz1[row2][2],2))*1.0); i=i+1; } } for(int k=1;k<=m;k++){ for (i=0;i<m-k;i++){ if (d[i]>d[i+1]){ e=d[i+1]; d[i+1]=d[i]; d[i]=e; } } } d[m]=0; for (i=m-1;i>=0;i--){ for (int row1=0; row1<n; row1++){ for (int row2=row1+1; row2<n; row2++){ if(d[i]!=d[i+1]){ if(sqrt((pow(sz1[row1][0]-sz1[row2][0],2)+pow(sz1[row1][1]-sz1[row2][1],2)+pow(sz1[row1][2]-sz1[row2][2],2))*1.0)==d[i]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz1[row1][0],sz1[row1][1],sz1[row1][2],sz1[row2][0],sz1[row2][1],sz1[row2][2],d[i]); }} } } } return 0; }
64
31,579
int point[MAX][3]; double d; struct { int x1,x2,y1,y2,z1,z2; double d; }dis[DISTANCE],mid; int n,m=0,i,j; int main(){ scanf("%d",&n); for(i=0;i<=n-1;i++){ scanf("%d%d%d",&point[i][0],&point[i][1],&point[i][2]); } for(i=0;i<=n-2;i++){ for(j=i+1;j<=n-1;j++){ dis[m].x1=point[i][0]; dis[m].x2=point[j][0]; dis[m].y1=point[i][1]; dis[m].y2=point[j][1]; dis[m].z1=point[i][2]; dis[m].z2=point[j][2]; dis[m].d=sqrt((dis[m].x1-dis[m].x2)*(dis[m].x1-dis[m].x2)+(dis[m].y1-dis[m].y2)*(dis[m].y1-dis[m].y2)+(dis[m].z1-dis[m].z2)*(dis[m].z1-dis[m].z2)); m++; } } for(i=0;i<=m-1;i++){ for(j=0;j<m-1;j++){ if(dis[j].d<dis[j+1].d){ mid=dis[j]; dis[j]=dis[j+1]; dis[j+1]=mid; } } } for(i=0;i<=m-1;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dis[i].x1,dis[i].y1,dis[i].z1,dis[i].x2,dis[i].y2,dis[i].z2,dis[i].d); } return 0; }
64
31,580
//************************** //*?????(14-4) ???? ** //*?????? 1200012888 ** //*???2013.12.11** //************************** struct //????????? Point ?? x y z ?? { int x; int y; int z; }Point[10]; //????? Point struct dis //????????? dis ?? ????d???????Point???????? { int pos_1; int pos_2; double d; }Dis[45]; int main() { int n; cin >> n; for (int i = 0 ; i < n ; i++) //??n????? { cin >> Point[i].x >> Point[i].y >> Point[i].z; } int count = 0; //count???? for (int i = 0 ; i < n ; i ++) { for (int j = i + 1 ; j < n ; j ++) { Dis[count].d = sqrt(1.0*(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)); //??????? Dis[count].pos_1 = i; //????????? Dis[count].pos_2 = j; count ++; } } for (int i = 0 ; i < count - 1 ; i ++) //????? { for (int j = 0 ; j < count - i - 1; j++) { if (Dis[j].d < Dis[j + 1].d) { struct dis temp; temp = Dis[j]; Dis[j] = Dis[j + 1]; Dis[j + 1] = temp; } } } for (int i = 0 ; i < count ; i ++) //???????? { cout << '(' << Point[Dis[i].pos_1].x << ','<< Point[Dis[i].pos_1].y << ','<< Point[Dis[i].pos_1].z << ')' << '-' << '(' << Point[Dis[i].pos_2].x << ','<< Point[Dis[i].pos_2].y << ','<< Point[Dis[i].pos_2].z << ')' << '='; cout << fixed << setprecision(2) << Dis[i].d << endl; } return 0; }
64
31,581
void main() { int i,j,k=0,p,n,c[100][3],d[100][6],temp; double t[100],temp2; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) scanf("%d",*(c+i)+j); } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { d[k][0]=c[i][0]; d[k][1]=c[i][1]; d[k][2]=c[i][2]; d[k][3]=c[j][0]; d[k][4]=c[j][1]; d[k][5]=c[j][2]; t[k]=(c[i][0]-c[j][0])*(c[i][0]-c[j][0]); t[k]+=(c[i][1]-c[j][1])*(c[i][1]-c[j][1]); t[k]+=(c[i][2]-c[j][2])*(c[i][2]-c[j][2]); t[k]=sqrt(t[k]); k++; } } for(i=1;i<k;i++) { for(j=0;j<k-i;j++) { if(t[j]<t[j+1]) { for(p=0;p<6;p++) { temp=d[j][p]; d[j][p]=d[j+1][p]; d[j+1][p]=temp; } temp2=t[j]; t[j]=t[j+1]; t[j+1]=temp2; } } } for(i=0;i<k;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],t[i]); }
64
31,582
struct point{ double x; double y; double z; }; struct range{ double a[3]; double b[3]; double x; }; int main(){ struct point points[10]; struct range ranges[200]; int n; cin>>n; for(int i=0;i<n;i++) cin>>points[i].x>>points[i].y>>points[i].z; int k=0; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++){ ranges[k].x=sqrt(pow((points[i].x-points[j].x),2)+pow((points[i].y-points[j].y),2)+pow((points[i].z-points[j].z),2)); ranges[k].a[0]=points[i].x;ranges[k].a[1]=points[i].y;ranges[k].a[2]=points[i].z; ranges[k].b[0]=points[j].x;ranges[k].b[1]=points[j].y;ranges[k].b[2]=points[j].z; k++;} struct range temp; for(int i=0;i<=k;i++) for(int j=0;j<=k-i;j++) if(ranges[j].x<ranges[j+1].x){ temp=ranges[j]; ranges[j]=ranges[j+1]; ranges[j+1]=temp; } for(int i=0;i<k;i++) cout<<fixed<<setprecision(0)<<'('<<ranges[i].a[0]<<','<<ranges[i].a[1]<<','<<ranges[i].a[2]<<')'<<'-'<<'('<<ranges[i].b[0]<<','<<ranges[i].b[1]<<','<<ranges[i].b[2]<<')'<<'='<<fixed<<setprecision(2)<<ranges[i].x<<endl; }
64
31,583
/* * ????????.cpp * Created on: 2011-1-1 * Author: ??? */ struct { int abs; int ver; int ord; } coor[10]; //?????? double fdis(int a, int b, int c, int d, int e, int f) { //?????? int m; double n; m = (a - d) * (a - d) + (b - e) * (b - e) + (c - f) * (c - f); n = sqrt((double) m); return n; } int main() { int n, i, j, k = 0, q, flag1[45], flag2[45], s, t; double dis[45], tempt; cin >> n; for (i = 0; i < n; i++) { cin >> coor[i].abs >> coor[i].ver >> coor[i].ord; } //???? for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { dis[k] = fdis(coor[i].abs, coor[i].ver, coor[i].ord, coor[j].abs, coor[j].ver, coor[j].ord); flag1[k] = i; flag2[k] = j; k++; } } for (k = 0; k < n * (n - 1) / 2; k++) { for (q = 0; q < n * (n - 1) / 2 - k - 1; q++) { if (dis[q] - dis[q + 1] < -1e-6) { s = flag1[q]; flag1[q] = flag1[q + 1]; flag1[q + 1] = s; t = flag2[q]; flag2[q] = flag2[q + 1]; flag2[q + 1] = t; tempt = dis[q]; dis[q] = dis[q + 1]; dis[q + 1] = tempt; //?? } } } for (k = 0; k < n * (n - 1) / 2; k++) { cout << "(" << coor[flag1[k]].abs << "," << coor[flag1[k]].ver << "," << coor[flag1[k]].ord << ")-(" << coor[flag2[k]].abs << "," << coor[flag2[k]].ver << "," << coor[flag2[k]].ord << ")" << "=" << fixed << setprecision(2) << dis[k] << endl; } //?? return 0; }
64
31,584
struct point{ int a[3]; int b[3]; double distant; }p[45],change; void swap(struct point p[],int k); void main() { int i,j,k=0,n; int 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]); for(j=0;j<n-1;j++) for(i=j+1;i<n;i++){ p[k].a[0]=x[j]; p[k].a[1]=y[j]; p[k].a[2]=z[j]; p[k].b[0]=x[i]; p[k].b[1]=y[i]; p[k].b[2]=z[i]; p[k++].distant=sqrt(pow(x[j]-x[i],2)+pow(y[j]-y[i],2)+pow(z[j]-z[i],2)); } swap(p,k-1); for(i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",p[i].a[0],p[i].a[1],p[i].a[2],p[i].b[0],p[i].b[1],p[i].b[2],p[i].distant); } void swap(struct point p[],int k) { int r,q; for(r=0;r<k;r++) for(q=0;q<k-r;q++) if(p[q].distant<p[q+1].distant){ change=p[q]; p[q]=p[q+1]; p[q+1]=change; } }
64
31,585
struct point { int x[3]; }pt[10]; struct str { struct point po[2]; float distance; }dis[50], temp; void main() { int n, i, j, num; scanf("%d",&n); for(i=0; i<n; i++) { for(j=0; j<=2; j++) scanf("%d",&pt[i].x[j]); } //?????? for(i=0; i<50; i++) dis[i].distance=0.0; for(i=0, num=0; i<n-1; i++)//???? { for(j=i+1; j<n; j++) { dis[num].po[0]=pt[i]; dis[num].po[1]=pt[j]; dis[num].distance=sqrt( abs(pt[i].x[0]-pt[j].x[0])*abs(pt[i].x[0]-pt[j].x[0])+abs(pt[i].x[1]-pt[j].x[1])*abs(pt[i].x[1]-pt[j].x[1])+abs(pt[i].x[2]-pt[j].x[2])*abs(pt[i].x[2]-pt[j].x[2]) ); num++; } } for(num=0, i=0; dis[i].distance>0.01; i++)//?num???????? { num++; } for(j=1; j<num ; j++) //???? { for(i=0; i<num-j; i++) { if( (dis[i+1].distance-dis[i].distance)>0.01 ) { temp=dis[i]; dis[i]=dis[i+1]; dis[i+1]=temp; } } } for(i=0; i<num; i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dis[i].po[0].x[0],dis[i].po[0].x[1],dis[i].po[0].x[2],dis[i].po[1].x[0],dis[i].po[1].x[1],dis[i].po[1].x[2],dis[i].distance); }
64
31,586
struct d { int x; int y; int z; }; struct p { struct d s1,s2; float res; }; float f(struct d s1,struct d s2) { double sum=0; sum=(s1.x-s2.x)*(s1.x-s2.x)+(s1.y-s2.y)*(s1.y-s2.y)+(s1.z-s2.z)*(s1.z-s2.z); return(sqrt(sum)); } void change(struct p pri[300],int n) { int i,j; struct p temp; for(i=0;i<n-1;i++) { for(j=0;j<n-1-i;j++) { if(pri[j].res<pri[j+1].res) { temp.s1.x=pri[j].s1.x; temp.s1.y=pri[j].s1.y; temp.s1.z=pri[j].s1.z; temp.s2.x=pri[j].s2.x; temp.s2.y=pri[j].s2.y; temp.s2.z=pri[j].s2.z; temp.res=pri[j].res; pri[j].s1.x=pri[j+1].s1.x; pri[j].s1.y=pri[j+1].s1.y; pri[j].s1.z=pri[j+1].s1.z; pri[j].s2.x=pri[j+1].s2.x; pri[j].s2.y=pri[j+1].s2.y; pri[j].s2.z=pri[j+1].s2.z; pri[j].res=pri[j+1].res; pri[j+1].s1.x=temp.s1.x; pri[j+1].s1.y=temp.s1.y; pri[j+1].s1.z=temp.s1.z; pri[j+1].s2.x=temp.s2.x; pri[j+1].s2.y=temp.s2.y; pri[j+1].s2.z=temp.s2.z; pri[j+1].res=temp.res; } } } } void main() { int n; int i,j; int k=0,h=0; float res[100]; struct d s[100]; struct p pri[300]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&s[i].x,&s[i].y,&s[i].z); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { res[k]=f(s[i],s[j]); pri[h].s1.x=s[i].x; pri[h].s1.y=s[i].y; pri[h].s1.z=s[i].z; pri[h].s2.x=s[j].x; pri[h].s2.y=s[j].y; pri[h].s2.z=s[j].z; pri[h].res=res[k]; h++; k++; } } change(pri,h); for(i=0;i<h;i++) //(0,0,0)-(1,1,1)=1.73// printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",pri[i].s1.x,pri[i].s1.y,pri[i].s1.z,pri[i].s2.x,pri[i].s2.y,pri[i].s2.z,pri[i].res); }
64
31,587
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
31,588
int main() { int n,i,j,k,p,l; double x[10],y[10],z[10],m; double d[100],c[100]; int a[100],b[100]; scanf("%d",&n); for(i=0;i<=n-1;++i) { scanf("%lf%lf%lf",&x[i],&y[i],&z[i]); } k=0; for(i=0;i<=n-2;++i) { for(j=i+1;j<=n-1;++j) { d[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; c[k]=d[k]; k++; } } for(i=0;i<=k-2;++i) { for(j=i+1;j<=k-1;++j) { if(c[i]<c[j]) { m=c[i]; c[i]=c[j]; c[j]=m; } } } for(i=0;i<=k-1;++i) { for(j=0;j<=k-1;++j) { if(c[i]==d[j]) { printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[a[j]],y[a[j ]],z[a[j]],x[b[j]],y[b[j]],z[b[j]],c[i]); d[j]=-1; } } } return 0; }
64
31,589
int main() { int n,i,j,k; int x[10],y[10],z[10]; double t; double d[45]; 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++) d[(j-i)+(n-1+n-i)*i/2-1]=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=0;i<n*(n-1)/2-1;i++) { for(j=i+1;j<n*(n-1)/2;j++) { if(d[i]<d[j]) {t=d[i];d[i]=d[j];d[j]=t; } } } for(k=0;k<n*(n-1)/2;k++) { if(d[k]!=d[k+1]) { for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(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])))-d[k]==0) {cout<<"("<<x[i]<<","<<y[i]<<","<<z[i]<<")-("<<x[j]<<","<<y[j]<<","<<z[j]<<")="; cout<<(fixed)<<setprecision(2)<<d[k]<<'\n'; } } } } } return 0; }
64
31,590
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
31,591
int point[10][3]={{0}}; float dis[10][10]={{0}}; float far[45]={0}; void bubblesort(int k) { for (int i=0;i<=k-1;i++) { for (int j=k;j>i;j--) { float tmp; if (far[j]>far[j-1]) { tmp=far[j]; far[j]=far[j-1]; far[j-1]=tmp; } } } } int main() { int n; cin>>n; for (int i=0;i<=n-1;i++) { cin>>point[i][0]>>point[i][1]>>point[i][2]; } int k=0; for (int i=0;i<=n-2;i++) { for (int j=i+1;j<=n-1;j++) { dis[i][j]=sqrt((float)( (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]))); far[k]=dis[i][j]; k++; } } bubblesort(k); for (int p=0;p<=k-1;) { for (int i=0;i<=n;i++) { for (int j=i;j<=n-1;j++) { if (dis[i][j]==far[p]) { cout<<"("<<point[i][0]<<","<<point[i][1]<<","<<point[i][2]<<")-("<<point[j][0]<<","<<point[j][1]<<","<<point[j][2]<<")="; printf("%.2f\n",far[p]); dis[i][j]=-1; goto loop; } } } loop:p++; } }
64
31,592
/************************* ??cpp4 ???? ??? 2013/12/12 **************************/ int main() { int n, i, j, k; cin >> n; struct point { int x; int y; int z; } a[12]; for (i=1; i<=n; i++) cin >> a[i].x >> a[i].y >> a[i].z; struct distance { int x1; int y1; int z1; int x2; int y2; int z2; double l; } b[60], temp; k=1; for (i=1; i <= n-1 ; i++) { for (j=i+1; j <= n; j++) { b[k].x1 = a[i].x; b[k].y1 = a[i].y; b[k].z1 = a[i].z; b[k].x2 = a[j].x; b[k].y2 = a[j].y; b[k].z2 = a[j].z; b[k].l = sqrt ( pow ((double)(a[i].x)- (double)(a[j].x) , 2.0) + pow ((double)(a[i].y)- (double)(a[j].y) , 2.0) + pow ((double)(a[i].z)- (double)(a[j].z) , 2.0)); k++; } } for (i=1; i<= n*(n-1)/2; i++) { for (j=1; j<=n*(n-1)/2-1 ; j++) { if (b[j].l < b[j+1].l) { temp = b[j]; b[j] = b[j+1]; b[j+1] = temp; } } } for (i=1; i<=n * (n-1) /2; i++) { cout << "(" << b[i].x1 << "," << b[i].y1 << "," << b[i].z1 << ")-"; cout << "(" << b[i].x2 << "," << b[i].y2 << "," << b[i].z2 << ")=" ; cout << fixed; cout<< setprecision(2) << b[i].l << endl; } return 0; }
64
31,593
int main(){ int x[10]; int y[10]; int z[10]; double c[10][10]; double w[100]; int k[50][4],l[50][4]; int i,n,q,o,j,d=0,a,b; double m; 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(q=i+1;q<n;q++){ m=1.0*(x[i]-x[q])*(x[i]-x[q])+1.0*(y[i]-y[q])*(y[i]-y[q])+1.0*(z[i]-z[q])*(z[i]-z[q]); c[i][q]=(double)sqrt(m); d++; } } j=d; for(o=0;o<j;o++){ w[o]=0; a=0;b=0; for(i=0;i<n-1;i++){ for(q=i+1;q<n;q++){ if(w[o]<c[i][q]){ w[o]=c[i][q]; a=i; b=q; } } } c[a][b]=-1; k[o][1]=x[a];k[o][2]=y[a];k[o][3]=z[a]; l[o][1]=x[b];l[o][2]=y[b];l[o][3]=z[b]; } for(o=0;o<d;o++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",k[o][1],k[o][2],k[o][3],l[o][1],l[o][2],l[o][3],w[o]); } return 0; }
64
31,594
typedef struct point { int x,y,z; }Point; double Distance(Point p1, Point p2) { double dist=0; dist = sqrtf((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) + (p1.z-p2.z)*(p1.z-p2.z)+0.0 ); return dist; } int main(int argc, char* argv[]) { int n, i, j, k=0, numtotal, maxpj=0, maxpi=0; double ** ppdDist, dMaxDist=0.0;//*p1Dist, Point * pcPoint; scanf("%d",&n); numtotal = n*(n-1)/2; //p1Dist = (double *)calloc(numtotal, sizeof(double)); ppdDist = (double**)calloc(n, sizeof(double*)); for (i=0; i<n; i++) { ppdDist[i] = (double *)calloc(n, sizeof(double)); } pcPoint = (Point *) calloc(n, sizeof(Point)); for (j=0; j<n; j++) { for (i=0; i<n; i++) { ppdDist[j][i] = 0.0; } } ////////////////////////////////////////////////////////////////////////// for (i=0; i<n; i++) { scanf("%d%d%d", &(pcPoint[i].x), &(pcPoint[i].y), &(pcPoint[i].z)); } for (j=0; j<n; j++) { for (i=j+1; i<n; i++) { ppdDist[j][i] =Distance(pcPoint[j], pcPoint[i]); } } for (k=0; k<numtotal; k++) { for (j=0; j<n; j++) { for (i=j+1; i<n; i++) { if (ppdDist[j][i]>dMaxDist) ///????????????????0 { maxpi = i; maxpj = j; dMaxDist = ppdDist[j][i]; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", pcPoint[maxpj].x, pcPoint[maxpj].y, pcPoint[maxpj].z, pcPoint[maxpi].x, pcPoint[maxpi].y, pcPoint[maxpi].z, dMaxDist); ppdDist[maxpj][maxpi] =0.0;// is out maxpi =0; maxpj =0; dMaxDist =0.0; } ////////////////////////////////////////////////////////////////////////// for (i=0; i<n; i++) { free(ppdDist[i]); } free(ppdDist); free(pcPoint); return 0; }
64
31,595
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
31,596
/* * julipaixu.cpp * ??:??????????n?????? * Created on: 2012-11-7 * Author: ??? */ int main() { int n,i=0,j=0,k=0; //????,n?????? double t1,d; //???????? int t2,t3; //???????? cin>>n; //??n int point[3][n], num[2][n*(n-1)/2];//??????point,num?????????? double distance [n*(n-1)/2];//??????distance,?????? for(i=0;i<n;i++) //?????? cin>>point[0][i]>>point[1][i]>>point[2][i]; for(i=0;i<n-1;i++) //????,????????,???????? for(j=i+1;j<n;j++) { d=(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[k]=sqrt(d); num[0][k]=i; num[1][k]=j; k++; } for(j=1;j<n*(n-1)/2;j++) //????????????,?????num????? for(i=0;i<(n*(n-1)/2)-j;i++) if(distance[i]<distance[i+1]) { t1=distance[i+1]; distance[i+1]=distance[i]; distance[i]=t1; t2=num[0][i+1]; num[0][i+1]=num[0][i]; num[0][i]=t2; t3=num[1][i+1]; num[1][i+1]=num[1][i]; num[1][i]=t3; } for(k=0;k<n*(n-1)/2;k++) //????????? { i=num[0][k]; j=num[1][k]; cout<<'('<<point[0][i]<<','<<point[1][i]<<','<<point[2][i]<<")-(" <<point[0][j]<<','<<point[1][j]<<','<<point[2][j]<<")=" <<fixed<<setprecision(2)<<distance[k]<<endl; } return 0; }
64
31,597
int main(){ int a[10][3],n; scanf("%d",&n); for(int i=0;i<n;i++) { for(int j=0;j<3;j++) { scanf("%d",&a[i][j]); } } struct{ int x1,x2,y1,y2,z1,z2; double d; }dis[45],mid; int m=0; for(int k=0;k<n-1;k++) { for(int l=k+1;l<n;l++) { dis[m].x1=a[k][0]; dis[m].x2=a[l][0]; dis[m].y1=a[k][1]; dis[m].y2=a[l][1]; dis[m].z1=a[k][2]; dis[m].z2=a[l][2]; dis[m].d=sqrt((dis[m].x1-dis[m].x2)*(dis[m].x1-dis[m].x2)+(dis[m].y1-dis[m].y2)*(dis[m].y1-dis[m].y2)+(dis[m].z1-dis[m].z2)*(dis[m].z1-dis[m].z2)); m++; } } for(int j = 1 ; j <= m ; j++){ for(int p=0; p<m-j; p++){ if(dis[p].d < dis[p+1].d){ mid= dis[p+1]; dis[p+1]=dis[p]; dis[p]=mid; } } } for(int w=0;w<m;w++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dis[w].x1,dis[w].y1,dis[w].z1,dis[w].x2,dis[w].y2,dis[w].z2,dis[w].d); } return 0; }
64
31,598
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
31,599
int main() { int n; float distance[150]; int k=1; int i=1,j=1,t=1; double temp; struct point { int x,y,z; } stu1[12]; struct ttt { int x1,y1,z1; int x2,y2,z2; } stu2[150]; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d %d %d",&stu1[i].x,&stu1[i].y,&stu1[i].z); for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { distance[k]=(float)sqrt((stu1[i].x-stu1[j].x)*(stu1[i].x-stu1[j].x)+(stu1[i].y-stu1[j].y)*(stu1[i].y-stu1[j].y) +(stu1[i].z-stu1[j].z)*(stu1[i].z-stu1[j].z)); stu2[k].x1=stu1[i].x; stu2[k].y1=stu1[i].y; stu2[k].z1=stu1[i].z; stu2[k].x2=stu1[j].x; stu2[k].y2=stu1[j].y; stu2[k].z2=stu1[j].z; k++;//k=0--k=n-1*n-2/2 } } t=k-1;//eg:n=4 k=7 t=6 for(j=0;j<=t-1;j++)//???? { for(i=1;i<=t-j;i++) { if(distance[i]<distance[i+1]) { temp=distance[i]; distance[i]=distance[i+1]; distance[i+1]=temp; temp=stu2[i].x1; stu2[i].x1=stu2[i+1].x1; stu2[i+1].x1=temp; temp=stu2[i].y1; stu2[i].y1=stu2[i+1].y1; stu2[i+1].y1=temp; temp=stu2[i].z1; stu2[i].z1=stu2[i+1].z1; stu2[i+1].z1=temp; temp=stu2[i].x2; stu2[i].x2=stu2[i+1].x2; stu2[i+1].x2=temp; temp=stu2[i].y2; stu2[i].y2=stu2[i+1].y2; stu2[i+1].y2=temp; temp=stu2[i].z2; stu2[i].z2=stu2[i+1].z2; stu2[i+1].z2=temp; } } } for(k=1;k<=t;k++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",stu2[k].x1,stu2[k].y1,stu2[k].z1,stu2[k].x2,stu2[k].y2,stu2[k].z2,distance[k]); return 0; }
64