label
stringlengths
1
2
index
stringlengths
1
5
code
stringlengths
87
8.24k
64
31700
int main(){ int zb[100][3],a,n,j,k,i; double b,jl[100],t; scanf("%d",&n); for( i=0;i<n;i++){ for(k=0;k<3;k++){ scanf("%d",&zb[i][k]); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ jl[10*i+j]=0; } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=((zb[i][0]-zb[j][0])*(zb[i][0]-zb[j][0]))+((zb[i][1]-zb[j][1])*(zb[i][1]-zb[j][1]))+((zb[i][2]-zb[j][2])*(zb[i][2]-zb[j][2])); jl[10*i+j]=sqrt(a); } } while(1){ t=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(jl[10*i+j]>t){ t=jl[10*i+j]; } } } if(t==0){ break; } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(jl[10*i+j]==t){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",zb[i][0],zb[i][1],zb[i][2],zb[j][0],zb[j][1],zb[j][2],t); jl[10*i+j]=0; } } } } return 0; }
64
31701
int main(){ int n,c,a,b,i,o,p,k; double e; scanf("%d",&n); double jl[n][n]; int x[n],y[n],z[n]; k=n*(n-1)/2; for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(a=0;a<n;a++){ b=a+1; while(b<n){ jl[a][b]=sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])+(z[a]-z[b])*(z[a]-z[b])); b++; } } e=0; for(i=0;i<k;i++){ for(a=0;a<n;a++){ b=a+1; while(b<n){ if(e<jl[a][b]){ e=jl[a][b]; o=a; p=b; } b++; } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[o],y[o],z[o],x[p],y[p],z[p],e); jl[o][p]=0; e=0; } return 0; }
64
31702
struct point { double x; double y; double z; }; struct points { double x1; double y1; double z1; double x2; double y2; double z2; double len; }; double length(struct point a,struct point b) { return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z)); } void main() { int m,n,i,j,k; struct point p[11]; struct points ps[101]; struct points pst; scanf("%d",&n); for(i=0;i<n;i++) scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z); k=0; for(i=0;i<n;i++)//p1 { for(j=i+1;j<n;j++)//p2 { if(i==j) continue; ps[k].x1=p[i].x; ps[k].y1=p[i].y; ps[k].z1=p[i].z; ps[k].x2=p[j].x; ps[k].y2=p[j].y; ps[k].z2=p[j].z; ps[k].len=length(p[i],p[j]); k++; } } m=n*(n-1)/2; for(i=1;i<m;i++) { for(j=0;j<m-i;j++) if(ps[j].len<ps[j+1].len) { pst=ps[j]; ps[j]=ps[j+1]; ps[j+1]=pst; } } for(i=0;i<m;i++) printf("(%g,%g,%g)-(%g,%g,%g)=%.2lf\n",ps[i].x1,ps[i].y1,ps[i].z1,ps[i].x2,ps[i].y2,ps[i].z2,ps[i].len); }
64
31703
struct distance { int p1[3]; int p2[3]; float dis; }d[50],t; int main() { int n; cin>>n; int a[10][3]; for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin>>a[i][j]; int p=0; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) {d[p].p1[0]=a[i][0]; d[p].p1[1]=a[i][1]; d[p].p1[2]=a[i][2]; d[p].p2[0]=a[j][0]; d[p].p2[1]=a[j][1]; d[p].p2[2]=a[j][2]; d[p].dis=sqrt(pow((double)(d[p].p1[0]-d[p].p2[0]),2)+pow((double)(d[p].p1[1]-d[p].p2[1]),2)+pow((double)(d[p].p1[2]-d[p].p2[2]),2)); p++;} for(int i=0;i<n*(n-1)/2;i++) for(int j=n*(n-1)/2-1;j>i;j--) { if(d[j].dis>d[j-1].dis){t=d[j];d[j]=d[j-1];d[j-1]=t;} } for(int i=0;i<n*(n-1)/2;i++) {printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",d[i].p1[0],d[i].p1[1],d[i].p1[2],d[i].p2[0],d[i].p2[1],d[i].p2[2],d[i].dis); cout<<endl;} return 0; }
64
31704
//*********************************************************************** //??????? //??????? //?????? //*********************************************************************** 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
31705
int main(){ int n,y; scanf("%d\n",&n); int x[1000][3]; double jl[100][100],o; for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i][0],&x[i][1],&x[i][2]); } for(int i=0;i<n-1;i++){ for(int k=i+1;k<n;k++){ jl[i][k]=sqrt((x[i][0]-x[k][0])*(x[i][0]-x[k][0])+(x[i][1]-x[k][1])*(x[i][1]-x[k][1])+(x[i][2]-x[k][2])*(x[i][2]-x[k][2])); } } int m,p,q,a=0; m=n*(n-1)/2; for(int i=0;i<9;i++){ if(a==m){ break; } for(int k=i+1;k<10;k++){ if(o<jl[i][k]){ o=jl[i][k]; p=i; q=k; } if(i==8&&k==9){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p][0],x[p][1],x[p][2],x[q][0],x[q][1],x[q][2],o); jl[p][q]=0; i=-1; o=0; a++; } } } return 0; }
64
31706
struct point { int x; int y; int z; }; double dis(struct point b,struct point c); int main() { int n,a,i=0,j=0,k; struct point str[10]; struct thr{ float d; int e; int f; }; struct thr temp={0}; struct thr str1[10000]={0}; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&str[i].x,&str[i].y,&str[i].z); i=0; for(j=0;j<n-1;j++) { k=j+1; for(k=j+1;k<n;k++) { str1[i].d=dis(str[j],str[k]); str1[i].e=j; str1[i].f=k; i++; } } a=i; j=0; k=0; for(j=0;j<a-1;j++) { k=0; for(k=0;k<a-j;k++) { if(str1[k].d<str1[k+1].d) {temp=str1[k]; str1[k]=str1[k+1]; str1[k+1]=temp; } } } i=0; for(i=0;i<a;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",str[str1[i].e].x,str[str1[i].e].y,str[str1[i].e].z,str[str1[i].f].x, str[str1[i].f].y,str[str1[i].f].z,str1[i].d); printf("\n"); } return 0; } double dis(struct point b,struct point c) { return sqrt(pow((b.x-c.x),2)+pow((b.y-c.y),2)+pow((b.z-c.z),2)); }
64
31707
int main(){ int n,i,j,k,b,c; int x[10],y[10],z[10]; double m[10][10],max=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n-1;i++){ for(j=0;j<n;j++){ m[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); } } for(k=0;k<n*(n-1)/2;k++){ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(max<m[i][j]){ max=m[i][j]; b=i; c=j; } } } if(max==0){break;} else{ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[b],y[b],z[b],x[c],y[c],z[c],max); m[b][c]=0; max=0; } } return 0; }
64
31708
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
31709
//************************** //*???????? * //*??????1000012797?* //*?????2010?12? * //************************** int main() { int i=0,j,n,count=0; double a[10]={0},b[10]={0},c[10]={0}; //????a,b,c?????????????????? cin>>n; //???? for(i=0;i<n;i++) { cin>>a[i]>>b[i]>>c[i]; } //?????? struct dis //??????????????? { int x; int y; double len; }d[45],temp; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { d[count].x=i; d[count].y=j; d[count].len=sqrt(pow(a[i]-a[j],2)+pow(b[i]-b[j],2)+pow(c[i]-c[j],2)); count++; } } //????? j=n*(n-1)/2; for(;j>0;j--) { for(i=0;i<n*(n-1)/2-1;i++) { if(d[i].len<d[i+1].len){temp=d[i];d[i]=d[i+1];d[i+1]=temp;} } } //????? for(i=0;i<n*(n-1)/2;i++) { cout<<"("<<(int)a[d[i].x]<<","<<(int)b[d[i].x]<<","<<(int)c[d[i].x]<<")"<<"-"<<"("<<(int)a[d[i].y]<<","<<(int)b[d[i].y]<<","<<(int)c[d[i].y]<<")"<<"="; cout<<fixed<<setprecision(2)<<d[i].len<<endl; } //?? return 0; //?? }
64
31710
/* *12-1 *??? 1200012851 *2012.12.11 *???? **/ double dis(int x, int y, int z) { double s; s = sqrt(x * x + y * y + z * z); return s; } int main() { int x[10], y[10], z[10]; struct distance { double d; int yi; int er; }d12[45], temp; int n, i, j, k = 0; 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++) { d12[k].d = dis(x[i] - x[j], y[i] - y[j], z[i] - z[j]); d12[k].yi = i; d12[k].er = j; k++; } } for (i = 1; i <= k - 1; i++) for (j = 0; j < k - i; j++) { if (d12[j].d < d12[j + 1].d) { temp = d12[j + 1]; d12[j + 1] = d12[j]; d12[j] = temp; } } for (i = 0; i < k; i++) { cout << "(" << x[d12[i].yi] << "," << y[d12[i].yi] << "," << z[d12[i].yi] << ")-(" << x[d12[i].er] << "," << y[d12[i].er] << "," << z[d12[i].er] << ")=" << fixed << setprecision(2) << d12[i].d << endl; } return 0; }
64
31711
int main (){ int n,i,j,a[10][3],b[100][3],c[100][3],k=0,e[100]; double d[100],l[100],x=0,m[100]; 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++) { d[k]=sqrt(1.0*((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2]))); b[k][0]=a[i][0]; b[k][1]=a[i][1]; b[k][2]=a[i][2]; c[k][0]=a[j][0]; c[k][1]=a[j][1]; c[k][2]=a[j][2]; k++; } } for(i=0;i<k;i++) { l[i]=d[i]; } for(i=0;i<k;i++) { for(j=0;j<k;j++) { if(l[j]>x) { x=l[j]; e[i]=j; } } l[e[i]]=0; x=0; } for(i=0;i<k;i++) { m[i]=d[e[i]]; } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[e[i]][0],b[e[i]][1],b[e[i]][2],c[e[i]][0],c[e[i]][1],c[e[i]][2],m[i]); } return 0; }
64
31712
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
31713
int main(){ int n; scanf("%d",&n); int x[100],y[100],z[100]; double a[100][100],b[100]; int i,j; for (i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } int q; q=0; for (j=0;j<n-1;j++){ for(i=j+1;i<n;i++){ a[j][i]=sqrt((x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])+(z[j]-z[i])*(z[j]-z[i])); b[q]=a[j][i]; q++; } } double e; int k; for(k=1;k<=q; k++){ for(i=0;i<q-k; i++){ if(b[i]>b[i+1]){ e=b[i+1]; b[i+1]=b[i]; b[i]=e; } } } int c; c=0; double d[100]; for(k=1;k<q;k++){ if(b[k-1]!=b[k]){ d[c]=b[k-1]; c++; } } if(b[q-1]!=b[q-2]){ d[c]=b[q-1]; c++; } for(k=c-1;k>0; k--){ for (j=0;j<n-1;j++){ for(i=j+1;i<n;i++){ if(d[k]==a[j][i]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[j],y[j],z[j],x[i],y[i],z[i],a[j][i]); } } } } for (j=0;j<n-1;j++){ for(i=j+1;i<n;i++){ if(d[0]==a[j][i]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[j],y[j],z[j],x[i],y[i],z[i],a[j][i]); } } } return 0; }
64
31714
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
31715
int main() { int n; //??n cin>>n; //??n float a[100],b[100],c[100],s[100],t; //??????a,b,c,???????????t int i,l,m,p=0,j,k,q,x,d[100],e[100]; //???????????d,e for(i=0;i<n;i++) { cin>>a[i]>>b[i]>>c[i]; //???? } for(l=0;l<n-1;l++) { for(m=l+1;m<n;m++) { s[p]=sqrt((a[l]-a[m])*(a[l]-a[m])+(b[l]-b[m])*(b[l]-b[m])+(c[l]-c[m])*(c[l]-c[m])); //???? d[p]=l; //??????????? e[p]=m; p++; } } for(j=0;j<p-1;j++) { for(k=j+1;k<p;k++) { if(s[k]>s[j]) //???????? { t=s[k]; s[k]=s[j]; s[j]=t; q=d[k]; d[k]=d[j]; //??????? d[j]=q; q=e[k]; e[k]=e[j]; e[j]=q; } if(s[k]==s[j]) { if(d[j]>d[k]||e[j]>e[k]) //?????????????????? { q=d[k]; d[k]=d[j]; d[j]=q; q=e[k]; e[k]=e[j]; e[j]=q; } } } } for(x=0;x<p;x++) { cout<<"("<<a[d[x]]<<","<<b[d[x]]<<","<<c[d[x]]<<")-("<<a[e[x]]<<","<<b[e[x]]<<","<<c[e[x]]<<")="; printf("%.2f\n",s[x]); //?? } return 0; }
64
31716
struct location { int x; int y; int z; } point[10], t; struct dis { int point1; int point2; double s; int num; } len[45], temp; int main() { int n, i, j,count = 0, p; double t; cin >> n; for (i = 0; i < n; i++) { cin >> point[i].x >> point[i].y >> point[i].z; } for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) { len[count].point1 = i; len[count].point2 = j; t = pow ((double) (point[i].x - point[j].x), 2) + pow ((double) (point[i].y - point[j].y), 2) + pow ((double) (point[i].z - point[j].z), 2); len[count].s = sqrt (t); len[count].num = count; ++count; } for (i = 0; i < count - 1; i++) { p = i; for (j = i +1; j < count; j++) { if (len[p].s < len[j].s) p = j; else if (len[p].s == len[j].s && len[p].num > len[j].num) p = j; } { temp = len[p]; len[p] = len[i]; len[i] = temp; } } for (i = 0; i < count; i++) { cout << "(" << point[len[i].point1].x << "," << point[len[i].point1].y << "," << point[len[i].point1].z << ")" << "-" << "(" << point[len[i].point2].x << "," << point[len[i].point2].y << "," << point[len[i].point2].z << ")" << "=" << fixed << setprecision(2) << len[i].s << endl; } return 0; }
64
31717
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
31718
//******************************** //*????*********************** //*??? 1300012920************** //******************************** int main() { int n , i , j; int x , y , z; int cnt = 0; //???????"zuobiao"???????? struct { int x; int y; int z; }zuobiao[10]; struct { int x1; int y1; int z1; int x2; int y2; int z2; int num1; int num2; double len; }len[50]; cin >> n;//?????? for(i = 0 ; i < n ; i++)//?????? { cin >> x >> y >> z; zuobiao[i].x = x; zuobiao[i].y = y; zuobiao[i].z = z; } //???????????????????????len? for(i = 0 ; i < n - 1 ; i++) for(j = i + 1 ; j < n ; j++) { len[cnt].x1 = zuobiao[i].x; len[cnt].y1 = zuobiao[i].y; len[cnt].z1 = zuobiao[i].z; len[cnt].x2 = zuobiao[j].x; len[cnt].y2 = zuobiao[j].y; len[cnt].z2 = zuobiao[j].z; len[cnt].num1 = i; len[cnt].num2 = j; len[cnt].len = sqrt((zuobiao[i].x - zuobiao[j].x) * (zuobiao[i].x - zuobiao[j].x) + (zuobiao[i].y - zuobiao[j].y) * (zuobiao[i].y - zuobiao[j].y) + (zuobiao[i].z - zuobiao[j].z) * (zuobiao[i].z - zuobiao[j].z)); cnt++; } for(i = 0 ; i < (n - 1) * n / 2 - 1 ; i++) for(j = i + 1 ; j < (n - 1) * n / 2 ; j++) { //????????????len[]???? if(len[i].len < len[j].len) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } //??????????????? if(len[i].len == len[j].len && len[i].num1 > len[j].num1) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } //???????????????????????? if(len[i].len == len[j].len && len[i].num1 == len[j].num1 && len[i].num2 > len[j].num2) { len[50] = len[i]; len[i] = len[j]; len[j] = len[50]; } } cout << fixed; for(j = 0 ; j < n * (n - 1) / 2 ; j++) cout << "(" << len[j].x1 << "," << len[j].y1 << "," << len[j].z1 << ")-(" << len[j].x2 << "," << len[j].y2 << "," << len[j].z2 <<")=" << setprecision(2) << len[j].len << endl; return 0; }
64
31719
void main() {int i,j,k=1,n,sa[100][3],b=0; double s[100]={0},point[10][3],a,c; scanf("%d",&n); for (i=0;i<n;i++) {scanf("%lf%lf%lf", &point[i][0],&point[i][1],&point[i][2]);} for (i=0;i<n-1;i++) {for (j=i+1;j<n;j++,k++) {c=(point[i][0]-point[j][0])*(point[i][0]-point[j][0])+(point[i][1]-point[j][1])*(point[i][1]-point[j][1])+(point[i][2]-point[j][2])*(point[i][2]-point[j][2]); s[k]=sqrt(c); sa[k][1]=i; sa[k][2]=j; } } for (i=1;i<k;i++) {for (j=k-1;j>1;j--) if (s[j]>s[j-1]+0.000001) {s[j-1]=s[j]+s[j-1]; s[j]=s[j-1]-s[j]; s[j-1]=s[j-1]-s[j]; b=sa[j][1]; sa[j][1]=sa[j-1][1]; sa[j-1][1]=b; b=sa[j][2]; sa[j][2]=sa[j-1][2]; sa[j-1][2]=b; } } for (i=1;i<k;i++) {b=sa[i][1]; printf("(%.0lf,%.0lf,%.0lf)-",point[b][0],point[b][1],point[b][2]); b=sa[i][2]; printf("(%.0lf,%.0lf,%.0lf)=",point[b][0],point[b][1],point[b][2]); printf("%.2lf\n", s[i]);} }
64
31720
int main() { int x[10],y[10],z[10],i,j,n,m=1,l; double d[46],p; cin>>n; for(i=0;i<n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { d[m]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); m=m+1; } for(i=1;i<m;i++) { for(j=1;j<=m-i;j++) { if(d[j]<d[j+1]) { p=d[j]; d[j]=d[j+1]; d[j+1]=p; } } } for(i=m;i>1;i--) { if(d[i]==d[i-1]) d[i]=0; } for (l=1;l<=m;l++) { if(d[l]!=0) { for(i=0;i<n-1;i++) { for(j=i;j<n;j++) { if(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))==d[l]) { cout<<"("<<x[i]<<","<<y[i]<<","<<z[i]<<")-("<<x[j]<<","<<y[j]<<","<<z[j]<<")="<<fixed<<setprecision(2)<<d[l]<<endl; } } } } } return 0; }
64
31721
int main() { int i,j,n,k=0,w; int x[10],y[10],z[10]; float d[45],dis[10][10],p=0,q=0,m=0,o=0; cin>>n; for(i=0;i<n;i++) { cin>>x[i]>>y[i]>>z[i]; } for(j=0;j<n-1;j++) { for(i=j+1;i<n;i++) { o=(x[j]-x[i])*(x[j]-x[i]); p=(y[j]-y[i])*(y[j]-y[i]); q=(z[j]-z[i])*(z[j]-z[i]); d[k]=sqrt(o+p+q); k++; } } for(w=1;w<n*(n-1)/2;w++) { for(k=0;k<(n*(n-1))/2-w;k++) { if(d[k]>d[k+1]) { m=d[k+1]; d[k+1]=d[k]; d[k]=m; } } } for(k=n*(n-1)/2-1;k>=0;k--) { if(d[k]!=d[k-1]) { for(j=0;j<n-1;j++) { for(i=j+1;i<n;i++) { o=(x[j]-x[i])*(x[j]-x[i]); p=(y[j]-y[i])*(y[j]-y[i]); q=(z[j]-z[i])*(z[j]-z[i]); if(d[k]==sqrt(o+p+q)) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f",x[j],y[j],z[j],x[i],y[i],z[i],d[k]); cout<<endl; } } }}} return 0; }
64
31722
int main(int argc, char *argv[]) { int n; int a[10][3],z[100][6]; float d[100],t; int i,j,l; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) { scanf("%d",&a[i][j]); } } int k=0; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { t=(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[k]=sqrt(t); z[k][0]=a[i][0];z[k][1]=a[i][1];z[k][2]=a[i][2];z[k][3]=a[j][0];z[k][4]=a[j][1];z[k][5]=a[j][2]; k++; } } for(i=k-1;i>0;i--) { for(j=0;j<i;j++) { if(d[j]<d[j+1]) { float e; e=d[j];d[j]=d[j+1];d[j+1]=e; int s; for(l=0;l<6;l++) { s=z[j][l];z[j][l]=z[j+1][l];z[j+1][l]=s; } } } } for(i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",z[i][0],z[i][1],z[i][2],z[i][3],z[i][4],z[i][5],d[i]); } return 0; }
64
31723
//???? 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
31724
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
31725
/* *???? distanceorder.cpp *?????? *????: 2012-11-10 *??????????????? */ int main() { int n, i, j, l, k = 0, b;//i,j,l????? cin >> n; int x[10] = { 0 }, y[10] = { 0 }, z[10] = { 0 }; // ??n????? int piont[6][100];// ????????? float a;//a????? float dis[100] = { 0 }; for (i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i]; // ???? for (i = 0; i <= n - 2; i++) for (j = i + 1; j <= n - 1; 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])); // ????????? piont[0][k] = x[i]; piont[1][k] = y[i]; piont[2][k] = z[i]; piont[3][k] = x[j]; piont[4][k] = y[j]; piont[5][k] = z[j]; // ??????????????? k = k + 1; }//?????k??? for (i = 0; i < k - 1; i++) for (j = 0; j < k - 1 - i; j++) if (dis[j] < dis[j + 1]) { a = dis[j]; dis[j] = dis[j + 1]; dis[j + 1] = a; for (l = 0; l <= 5; l++) {b = piont[l][j]; piont[l][j] = piont[l][j + 1]; piont[l][j + 1] = b;} } // ????????????? for (i = 0; i < k ; i++) cout << fixed << setprecision(0) << "(" << piont[0][i] << "," << piont[1][i] << "," << piont[2][i] << ")-(" << piont[3][i] << "," << piont[4][i] << "," << piont[5][i] << ")=" << fixed << setprecision(2) << dis[i] << endl; // ???????? return 0; }
64
31726
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
31727
int main(){ int u=0,i,k,t,n,j,s,g,a[1000],b[1000],c[1000],e[1000],f[1000]; double d[1000],m; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); } for(j=0;j<n-1;j++){ for(i=j,t=j+1;t<n;t++){ d[u]=sqrt(pow(a[i]-a[t],2)+pow(b[i]-b[t],2)+pow(c[i]-c[t],2)); e[u]=i; f[u]=t; u++; } } for(k=1;k<=u;k++){ for(i=0;i<u-k;i++){ if(d[i]<d[i+1]){ m=d[i]; d[i]=d[i+1]; d[i+1]=m; s=e[i]; e[i]=e[i+1]; e[i+1]=s; g=f[i]; f[i]=f[i+1]; f[i+1]=g; } } } for(i=0;i<u;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[e[i]],b[e[i]],c[e[i]],a[f[i]],b[f[i]],c[f[i]],d[i]); } return 0; }
64
31728
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
31729
int main() { int n; cin>>n; int a[20][3]; double ss[200]; int s[200][7]; for (int i=0;i<n;i++) { for (int j=0;j<3;j++) cin>>a[i][j]; } int x,y,z,count=0; for (int i=0;i<n;i++) for (int j=i+1;j<n;j++) { x=a[i][0]-a[j][0]; y=a[i][1]-a[j][1]; z=a[i][2]-a[j][2]; ss[count]=sqrt(x*x+y*y+z*z); s[count][1]=a[i][0]; s[count][2]=a[i][1]; s[count][3]=a[i][2]; s[count][4]=a[j][0]; s[count][5]=a[j][1]; s[count][6]=a[j][2]; count++; } int temp; for (int i=0;i<count;i++) for (int j=0;j<count-1;j++) { if (ss[j]<ss[j+1]) { double temp2=ss[j]; ss[j]=ss[j+1]; ss[j+1]=temp2; temp=s[j][1]; s[j][1]=s[j+1][1]; s[j+1][1]=temp; temp=s[j][2]; s[j][2]=s[j+1][2]; s[j+1][2]=temp; temp=s[j][3]; s[j][3]=s[j+1][3]; s[j+1][3]=temp; temp=s[j][4]; s[j][4]=s[j+1][4]; s[j+1][4]=temp; temp=s[j][5]; s[j][5]=s[j+1][5]; s[j+1][5]=temp; temp=s[j][6]; s[j][6]=s[j+1][6]; s[j+1][6]=temp; } } for (int i=0;i<count;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",s[i][1],s[i][2],s[i][3],s[i][4],s[i][5],s[i][6],ss[i]); return 0; }
64
31730
int main(){ int n,l=0,x[101],y[101],z[101],a[101],b[101],i; double m[101]; scanf("%d\n",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(int k=0;k<n-1;k++){ for(i=k+1;i<n;i++){ m[l]=sqrt(1.0*(x[k]-x[i])*(x[k]-x[i])+1.0*(y[k]-y[i])*(y[k]-y[i])+1.0*(z[k]-z[i])*(z[k]-z[i])); a[l]=k; b[l]=i; l++; } } for(int k=1;k<=l;k++){ double e; for(i=0;i<l-k;i++){ if(m[i]<m[i+1]){ e=m[i+1]; m[i+1]=m[i]; m[i]=e; e=a[i+1]; a[i+1]=a[i]; a[i]=e; e=b[i+1]; b[i+1]=b[i]; b[i]=e; } } } for(i=0;i<l;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],m[i]);} return 0; }
64
31731
int main(){ int i,j,k,m,n,x; double e; scanf("%d",&n); int sz[10][3]; for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&sz[i][j]); } } double s[50]; m=0; double zong; int a[50][3]; int b[50][3]; for(j=0;j<(n-1);j++){ for(i=j+1;i<=n-1;i++){ zong=0; for(k=0;k<3;k++){ a[m][k]=sz[j][k]; b[m][k]=sz[i][k]; zong=zong+pow((a[m][k]-b[m][k]),2); } s[m]=sqrt(zong); m=m+1; } } for(j=0;j<m-1;j++){ for(i=0;i<m-1-j;i++){ if(s[i]<s[i+1]){ e=s[i]; s[i]=s[i+1]; s[i+1]=e; for(k=0;k<3;k++){ x=a[i][k]; a[i][k]=a[i+1][k]; a[i+1][k]=x; x=b[i][k]; b[i][k]=b[i+1][k]; b[i+1][k]=x; } } } } for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],b[i][0],b[i][1],b[i][2],s[i]); } return 0; }
64
31732
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
31733
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
31734
int main() { int i,n,j,k=0; struct zuobiao { int x; int y; int z; } a[10]; struct juli { double d; struct zuobiao a1; struct zuobiao b1; } b[100],tem; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z); } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { b[k].d=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z)); b[k].a1=a[i]; b[k].b1=a[j]; k++; } } n=n*(n-1)/2; for(i=1;i<n;i++) //???? { for(j=i;j>0;j--) { if(b[j].d>b[j-1].d) { tem=b[j]; b[j]=b[j-1]; b[j-1]=tem; } } } for(i=0;i<n;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i].a1.x,b[i].a1.y,b[i].a1.z,b[i].b1.x,b[i].b1.y,b[i].b1.z,b[i].d); } return 0; }
64
31735
struct node { int x,y,z; }p[10]; struct edge{ int node1,node2; double dis; }t[100]; double dist(int a,int b) { return sqrt((p[a].x-p[b].x)*(p[a].x-p[b].x)+(p[a].y-p[b].y)*(p[a].y-p[b].y)+(p[a].z-p[b].z)*(p[a].z-p[b].z)); } int judge(int x,int y) { if (t[x].node1<t[y].node1 || (t[x].node1==t[y].node1 && t[x].node2<t[y].node2)) return 0; else return 1; } int main() { int n,l=0,a,b,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++) { l++; t[l].dis=dist(i,j); t[l].node1=i; t[l].node2=j; } } for (i=1;i<=l;i++) { for (j=i+1;j<=l;j++) { if (t[i].dis<t[j].dis || (t[i].dis==t[j].dis && judge(i,j))) { t[56]=t[i]; t[i]=t[j]; t[j]=t[56]; } } } for (i=1;i<=l;i++) { a=t[i].node1; b=t[i].node2; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",p[a].x,p[a].y,p[a].z,p[b].x,p[b].y,p[b].z,t[i].dis); } return 0; }
64
31736
int main(){ int n,x[100],y[100],z[100],i,j,k,a[100],b[100],c[100],d[100],e[100],f[100],m,o; double dis[1000],p; scanf("%d",&n); m=(n-1)*n/2; for(i=1;i<=n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(i=1,k=1;i<=n-1;i++){ for(j=i+1;j<=n;j++){ a[k]=x[i]; b[k]=y[i]; c[k]=z[i]; d[k]=x[j]; e[k]=y[j]; f[k]=z[j]; dis[k]=sqrt((1.0*a[k]-d[k])*(a[k]-d[k])+(b[k]-e[k])*(b[k]-e[k])+(c[k]-f[k])*(c[k]-f[k])); k++; } } for(i=1;i<=m;i++){ for(k=1;k<=m-i;k++){ if(dis[k]<dis[k+1]){ o=a[k+1]; a[k+1]=a[k]; a[k]=o; o=b[k+1]; b[k+1]=b[k]; b[k]=o; o=c[k+1]; c[k+1]=c[k]; c[k]=o; o=d[k+1]; d[k+1]=d[k]; d[k]=o; o=e[k+1]; e[k+1]=e[k]; e[k]=o; o=f[k+1]; f[k+1]=f[k]; f[k]=o; p=dis[k+1]; dis[k+1]=dis[k]; dis[k]=p; } } } for(i=1;i<=m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],d[i],e[i],f[i],dis[i]); } return 0; }
64
31737
double julishi(int a,int b,int c,int x,int y,int z); int main(){ int n,dzb,i,j,k,m,N; scanf("%d",&n); int x[1000],y[1000],z[1000]; N=3*n; for(i=0;i<N;i++){ scanf("%d%d%d",&(x[i]),&(y[i]),&(z[i])); } m=n*(n-1)/2; double jl[10000]; int ax[10000],ay[10000],az[10000]; int bx[10000],by[10000],bz[10000]; k=1; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ jl[k]=julishi(x[i],y[i],z[i],x[j],y[j],z[j]); ax[k]=x[i],ay[k]=y[i],az[k]=z[i],bx[k]=x[j],by[k]=y[j],bz[k]=z[j]; k++; } } double e; int f; for(k=1;k<=m;k++){ for(j=1;j<=m-k;j++){ if(jl[j]<jl[j+1]){ e=jl[j]; jl[j]=jl[j+1]; jl[j+1]=e; f=ax[j];ax[j]=ax[j+1];ax[j+1]=f; f=ay[j];ay[j]=ay[j+1];ay[j+1]=f; f=az[j];az[j]=az[j+1];az[j+1]=f; f=bx[j];bx[j]=bx[j+1];bx[j+1]=f; f=by[j];by[j]=by[j+1];by[j+1]=f; f=bz[j];bz[j]=bz[j+1];bz[j+1]=f; } } } for(j=1; j<=m;j++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",ax[j],ay[j],az[j],bx[j],by[j],bz[j],jl[j]); } return 0; } double julishi(int a,int b,int c,int x,int y,int z){ double jl; int sum; sum=(a-x)*(a-x)+(b-y)*(b-y)+(c-z)*(c-z); jl=sqrt(sum); return jl; }
64
31738
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
31739
void main() { float max,s[11][11],z[11][3]; int i,j,n,x,y,k; scanf("%d",&n); memset(s,0,sizeof(s)); memset(z,0,sizeof(z)); for (i=1;i<=n;i++) { scanf("%f%f%f",&z[i][0],&z[i][1],&z[i][2]); for (j=1;j<i;j++) { s[j][i]=sqrt((z[i][0]-z[j][0])*(z[i][0]-z[j][0])+(z[i][1]-z[j][1])*(z[i][1]-z[j][1])+(z[i][2]-z[j][2])*(z[i][2]-z[j][2])); } } for (i=1;i<=n*(n-1)/2;i++) { max=s[1][2]; x=1;y=2; for (j=1;j<n;j++) for (k=j+1;k<=n;k++) { if (s[j][k]>max) { x=j;y=k; max=s[j][k]; //printf("%.2f\n",max); } } printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",z[x][0],z[x][1],z[x][2],z[y][0],z[y][1],z[y][2],s[x][y]); s[x][y]=0; } }
64
31740
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
31741
struct distance { int point1; int point2; double dis; } a[200], t; int main() { int x[20] = {0}, y[20] = {0}, z[20] = {0}, n, i, j, k = 1; cin >> n; for (i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> z[i]; } for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++, k++) { a[k].dis = sqrt(pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0) + pow(z[i] - z[j], 2.0)); a[k].point1 = i; a[k].point2 = j; } } for (k = 1; k <= n * (n - 1) / 2; k++) { for (i = 1; i <= n * (n - 1) / 2 + 1 - k; i++) { if (a[i].dis < a[i + 1].dis) { t = a[i]; a[i] = a[i + 1]; a[i + 1] = t; } } } for (i = 1; i <= n * (n - 1) / 2; i++) { cout << "(" << x[a[i].point1] << "," << y[a[i].point1] << "," << z[a[i].point1] << ")-(" << x[a[i].point2] << "," << y[a[i].point2] << "," << z[a[i].point2] << ")=" << fixed << setprecision(2) << a[i].dis << endl; } return 0; }
64
31742
struct point { double x; double y; double z; }; struct dianju { double d; struct point p1; struct point p2; }; void main() { double julijisuan(struct point p1,struct point p2); int n,i,j,k; struct point p[m]; struct dianju D[m*(m-1)/2]; struct dianju a; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z); } for(i=0,k=0;i<n-1;i++) { for(j=i;j<n-1;j++,k++) { D[k].p1=p[i]; D[k].p2=p[j+1]; D[k].d=julijisuan(D[k].p1,D[k].p2); } } for(i=0;i<n*(n-1)/2;i++) { for(j=0;j<n*(n-1)/2-1;j++) { if(D[j].d<D[j+1].d) { a=D[j]; D[j]=D[j+1]; D[j+1]=a; } } } for(i=0;i<n*(n-1)/2;i++) { printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",D[i].p1.x,D[i].p1.y,D[i].p1.z,D[i].p2.x,D[i].p2.y,D[i].p2.z,D[i].d); } } double julijisuan(struct point p1,struct point p2) { return(sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)+(p1.z-p2.z)*(p1.z-p2.z))); }
64
31743
int main(){ int m,n,i,h=1,l=0,k,j,x[11],y[11],z[11],N; double s[50],p,d[50],t; scanf("%d",&n); N=(((n-1)*n)/2); /*???N?*/ for(i=0;i<n;i++){ scanf("%d %d %d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ /*???????????????*/ s[l]=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]));/*????sl*/ l++;/*?????s[l]*/ } } for(l=0;l<N;l++){/*??????sl????????*/ m=l; for(j=l+1;j<N;j++){ if (s[m]<s[j]){ p=s[j]; s[j]=s[m]; s[m]=p; } } } d[0]=s[0],j=1;/*????????j-1?????d[0]??*/ for(l=1;l<N;l++){/*?????????sl???????????*/ if(d[j-1]!=s[l]){ d[j]=s[l]; j++; h++; } } for (j=0;j<h;j++){/*??????d[j]??*/ for(i=0;i<n;i++){ for(k=i+1;k<n;k++){ t=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k])); if(d[j]==t){/*??d[j]???x[i],x[k]??????*/ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[k],y[k],z[k],d[j]); } } } } return 0; }
64
31744
//*********************************** //** ???Dec 11, 2013 - ???? ** //** ?????? 1300012719 ** //** ???2013.12.14 ** //*********************************** int main() { int i, j, k = 0, n; //k???n???????? struct p //???p???????? { int x; int y; int z; } p[10]; struct ptp //???ptp?????????????????,?????45,????????????? { int x1; int y1; int z1; int x2; int y2; int z2; double dis; } ptp[46]; cin >> n; //????????????? for (i = 0; i < n; i++) cin >> p[i].x >> p[i].y >> p[i].z; for (i = 0; i < n - 1; i++) //?????????,????????????? for (j = i + 1; j < n; j++) { ptp[k].x1 = p[i].x; ptp[k].x2 = p[j].x; ptp[k].y1 = p[i].y; ptp[k].y2 = p[j].y; ptp[k].z1 = p[i].z; ptp[k].z2 = p[j].z; ptp[k].dis = sqrt((ptp[k].x1-ptp[k].x2) * (ptp[k].x1-ptp[k].x2) + (ptp[k].y1-ptp[k].y2) * (ptp[k].y1-ptp[k].y2) + (ptp[k].z1-ptp[k].z2) * (ptp[k].z1-ptp[k].z2)); k++; } for (i = 0; i < k - 1; i++) //??????ptp[45],?????????ptp??????? for (j = 0; j < k - 1 - i; j++ ) { if (ptp[j].dis < ptp[j + 1].dis) { ptp[45] = ptp[j]; ptp[j] = ptp[j + 1]; ptp[j + 1] = ptp[45]; } } for (i = 0; i < k; i++) //??????????? cout << "(" << ptp[i].x1 << "," << ptp[i].y1 << "," << ptp[i].z1 << ")-(" << ptp[i].x2 << "," << ptp[i].y2 << "," << ptp[i].z2 << ")=" << fixed << setprecision(2) << ptp[i].dis << endl; return 0; }
64
31745
typedef struct { int x,y,z; } Point; typedef struct { double len; int pt1,pt2; } Distance; double CalDis(Point pt1,Point pt2) { return sqrt((double)(pt1.x-pt2.x)*(pt1.x-pt2.x)+(pt1.y-pt2.y)*(pt1.y-pt2.y)+(pt1.z-pt2.z)*(pt1.z-pt2.z)); } int cmp( const void *a ,const void *b) { if((*(Distance *)a).len != (*(Distance *)b).len) return (*(Distance *)a).len > (*(Distance *)b).len ? -1 : 1; //return ((Distance *)b)->len - ((Distance *)a)->len; //return (*(Distance *)a).pt1 > (*(Distance *)b).pt1 ? 1 : -1; if(((Distance *)a)->pt1 != ((Distance *)b)->pt1) return ((Distance *)a)->pt1 - ((Distance *)b)->pt1; return ((Distance *)a)->pt2 - ((Distance *)b)->pt2; } /*int cmp( const void *a ,const void *b) { if((*(Distance *)b).len != (*(Distance *)a).len) return (*(Distance *)b).len > (*(Distance *)a).len ? 1 : -1; else return (*(Distance *)a).pt1 > (*(Distance *)b).pt1 ? 1 : -1; }*/ Distance ds[N]; int main() { int n,count=0,i,j; Point pts[10]; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d %d %d",&pts[i].x,&pts[i].y,&pts[i].z); for(i=0;i<n;i++) for(j=i+1;j<n;j++) { ds[count].len=CalDis(pts[i],pts[j]); ds[count].pt1=i; ds[count++].pt2=j; } qsort(ds,count,sizeof(ds[0]),cmp); for(i=0;i<count;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",pts[ds[i].pt1].x,pts[ds[i].pt1].y, pts[ds[i].pt1].z,pts[ds[i].pt2].x,pts[ds[i].pt2].y,pts[ds[i].pt2].z,ds[i].len); return 0; }
64
31746
int main() { int n,i,j,count=1; double x[20],y[20],z[20],t; cin>>n; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i];//?xyz?? } struct position//????????????? { double x;double a; double y;double b; double z;double c; double d; }p[100]; for(i=1;i<=n;i++) { for(j=i+1;j<=n;j++) { p[count].x=x[i];p[count].a=x[j]; p[count].y=y[i];p[count].b=y[j]; p[count].z=z[i];p[count].c=z[j]; p[count].d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));//??? count++; } } for(i=count-1;i>0;i--) { for(j=1;j<i;j++) { if(p[j].d<p[j+1].d) { swap(p[j].x,p[j+1].x); swap(p[j].y,p[j+1].y); swap(p[j].z,p[j+1].z); swap(p[j].a,p[j+1].a); swap(p[j].b,p[j+1].b); swap(p[j].c,p[j+1].c); swap(p[j].d,p[j+1].d);//?????????? } } } for(i=1;i<=count-1;i++) { cout<<'('<<(int)p[i].x<<','<<(int)p[i].y<<','<<(int)p[i].z<<')'<<'-'<<'('<<(int)p[i].a<<','<<(int)p[i].b<<','<<(int)p[i].c<<')'<<'='<<fixed<<setprecision(2)<<p[i].d<<endl; } return 0; }
64
31747
float dis(int a[3],int b[3]) { float d=0; for (int i=0;i<3;i++) d+=(a[i]-b[i])*(a[i]-b[i]); d=pow(d,0.5); return d; } int main() { int n,x=0,y; scanf("%d",&n); int a[n][3]; y=n*(n-1)/2; float b[y][3],m[3]; for (int i=0;i<n;i++) for (int j=0;j<3;j++) scanf("%d",&a[i][j]); for (int i=0;i<n-1;i++) for (int j=i+1;j<n;j++) { b[x][0]=i; b[x][1]=j; b[x][2]=dis(a[i],a[j]); x++; } for (int j=y-2;j>=0;j--) for (int i=0;i<=j;i++) if (b[i][2]<b[i+1][2]) for (int k=0;k<3;k++) { m[k]=b[i][k]; b[i][k]=b[i+1][k]; b[i+1][k]=m[k]; } for (int i=0;i<y;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[(int)b[i][0]][0],a[(int)b[i][0]][1],a[(int)b[i][0]][2],a[(int)b[i][1]][0],a[(int)b[i][1]][1],a[(int)b[i][1]][2],b[i][2]); }
64
31748
int main(){ int n,i,k,s,m; int zb[10][3]; double d[45][7],e; scanf("%d",&n); for(i=0;i<n;i++){ for(s=0;s<3;s++){ scanf("%d",&(zb[i][s])); } } s=0; for(i=0;i<=n-2;i++){ for(k=1;i+k<=n-1;k++){ m=(zb[i][0]-zb[i+k][0])*(zb[i][0]-zb[i+k][0])+(zb[i][1]-zb[i+k][1])*(zb[i][1]-zb[i+k][1])+(zb[i][2]-zb[i+k][2])*(zb[i][2]-zb[i+k][2]); d[s][0]=sqrt(m); d[s][1]=zb[i][0]; d[s][2]=zb[i][1]; d[s][3]=zb[i][2]; d[s][4]=zb[i+k][0]; d[s][5]=zb[i+k][1]; d[s][6]=zb[i+k][2]; s++; } } m=s; for(k=1;m-k>0;k++){ for(i=0;i<m-k;i++){ if(d[i][0]<d[i+1][0]){ for(s=0;s<7;s++){ e=d[i][s]; d[i][s]=d[i+1][s]; d[i+1][s]=e; } } } } for(i=0;i<m;i++){ printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",d[i][1],d[i][2],d[i][3],d[i][4],d[i][5],d[i][6],d[i][0]); } return 0; }
64
31749
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
31750
int t[2000]; double id(int a,int b,int c) { return sqrt(a*a+b*b+c*c); } int main() { int i,j,n,m,s=0,x[20],y[20],z[20],q[200],w[200]; double d[200]; scanf("%d",&m); for(i=0;i<m;i++) { scanf("%d%d%d",&x[i],&y[i],&z[i]); } n=m*(m-1)/2; for(i=0;i<m-1;i++) for(j=i+1;j<m;j++) { d[s]=id(x[i]-x[j],y[i]-y[j],z[i]-z[j]); q[s]=i; w[s]=j; s++; } //for(i=0;i<=n+1;i++) //{for(j=0;j<=n+1;j++)printf("%d ",a[i][j]);printf("\n");} for(i=1;i<=n;i++) for(j=0;j<n-i;j++) if(d[j]<d[j+1]) { swap(q[j],q[j+1]); swap(w[j],w[j+1]); swap(d[j],d[j+1]); } for(j=0;j<n;j++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[q[j]],y[q[j]],z[q[j]],x[w[j]],y[w[j]],z[w[j]],d[j]); return 0; }
64
31751
/* * 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
31752
int main() { int i,j,k,l,m,n,num,tempi; int x[10],y[10],z[10]; float d[100]; float tempd; int dp1[100],dp2[100]; //scan the numbers scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&x[i],&y[i],&z[i]); } num=-1; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { num++; d[num]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); dp1[num]=i; dp2[num]=j; } num++; for(i=0;i<num-1;i++) for(j=i+1;j<num;j++) { if(d[j]>d[i]) { //swap d tempd=d[j]; d[j]=d[i]; d[i]=tempd; //swap dp1 tempi=dp1[i]; dp1[i]=dp1[j]; dp1[j]=tempi; //swap dp2 tempi=dp2[i]; dp2[i]=dp2[j]; dp2[j]=tempi; } if(d[j]==d[i]&&(dp1[j]<dp1[i]||dp1[j]==dp1[i]&&dp2[j]<dp2[i])) { tempd=d[j]; d[j]=d[i]; d[i]=tempd; tempi=dp1[i]; dp1[i]=dp1[j]; dp1[j]=tempi; tempi=dp2[i]; dp2[i]=dp2[j]; dp2[j]=tempi; } } for(i=0;i<num;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[dp1[i]],y[dp1[i]],z[dp1[i]],x[dp2[i]],y[dp2[i]],z[dp2[i]],d[i]); }
64
31753
int main() { int n,i,j,k,p=0,x[11][3],y[100][3],z[100][3]; double d1[45]={0},d[45]; cin>>n; for(i=0;i<n;i++) for(j=0;j<3;j++) { cin>>x[i][j]; } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { for(k=0;k<3;k++) { d1[p]=d1[p]+((double)x[i][k]-(double)x[j][k])*((double)x[i][k]-(double)x[j][k]); y[p][k]=x[i][k]; z[p][k]=x[j][k]; } d[p]=sqrt(d1[p]); p++; } } for(i=0;i<p-1;i++) {for(j=p-2;j>=i;j--) {if(d[j]<d[j+1]) { swap(d[j],d[j+1]); swap(y[j][0],y[j+1][0]); swap(y[j][1],y[j+1][1]); swap(y[j][2],y[j+1][2]); swap(z[j][0],z[j+1][0]); swap(z[j][1],z[j+1][1]); swap(z[j][2],z[j+1][2]); }}} for(i=0;i<p;i++) {cout<<"("<<y[i][0]<<","<<y[i][1]<<","<<y[i][2]<<")"<<"-"<<"("<<z[i][0]<<","<<z[i][1]<<","<<z[i][2]<<")"<<"="<<fixed<<setprecision(2)<<d[i]<<endl;} return 0; }
64
31754
/* * shuzu.2.3.cpp * * Created on: 2012-11-19 * Author: wangrunhui */ int main() { int n,a[10][3],i,j,k ,ai[100],ak[100],l = 0,tempi,tempk;//a?????i,j,k,l???????ai?ak?????????? double d[100],tempd;//d???? cin >> n; for ( i = 0; i < n; i ++)//?a?? { for ( j = 0; j < 3; j ++) cin >> a[i][j]; } for ( i = 0; i < n; i ++)//???????????????????? { for ( k = i + 1; k < n; k ++ )//???i+1????????????? { d[l] = sqrt( (a[i][0] - a[k][0]) * (a[i][0] - a[k][0]) + (a[i][1] - a[k][1]) * (a[i][1] - a[k][1]) + (a[i][2] - a[k][2]) * (a[i][2] - a[k][2]) ); ai[l] = i;//?????? ak[l] = k; l ++;//????????? } } for ( i = 0 ; i < l - 1; i ++)//???????????????????????????? { for ( j = 0; j < l - i - 1; j ++) { if ( d[j] < d[j + 1]) { tempd = d[j]; d[j] = d[j + 1]; d[j + 1] = tempd; tempi = ai[j]; ai[j] = ai[j + 1]; ai[j + 1] = tempi; tempk = ak[j]; ak[j] = ak[j + 1]; ak[j + 1] = tempk; } } } for ( j = 0; j < l ; j ++)//?????? { i = ai[j]; k = ak[j]; cout << '(' << a[i][0] << ','<< a[i][1] << ',' << a[i][2] << ")-("; cout << a[k][0] << ',' << a[k][1] << ',' << a[k][2]<< ")="; cout<< fixed << setprecision(2) <<d[j]<<endl;//??????? } }
64
31755
void main(){ int n,a[30],b[45][6],btemp[45][6],i,j,k,T; double d,c[45],temp; scanf("%d",&n); T=n*(n-1)/2; for(i=0;i<3*n;i++){ scanf("%d",&a[i]); } j=0; for(i=0;i<n-1;i++){ for(k=1;k<=(n-1)-i;k++){ d=sqrt((a[3*i]-a[3*i+3*k])*(a[3*i]-a[3*i+3*k])+(a[3*i+1]-a[3*i+3*k+1])*(a[3*i+1]-a[3*i+3*k+1])+(a[3*i+2]-a[3*i+3*k+2])*(a[3*i+2]-a[3*i+3*k+2])); b[j][0]=a[3*i]; b[j][3]=a[3*i+3*k]; b[j][1]=a[3*i+1]; b[j][4]=a[3*i+3*k+1]; b[j][2]=a[3*i+2]; b[j][5]=a[3*i+3*k+2]; c[j]=d; j++; } } for(i=0;i<T;i++){ for(j=0;j<T-i;j++){ if(c[j]<c[j+1]){ temp=c[j]; c[j]=c[j+1]; c[j+1]=temp; btemp[j][0]=b[j][0]; btemp[j][1]=b[j][1]; btemp[j][2]=b[j][2]; btemp[j][3]=b[j][3]; btemp[j][4]=b[j][4]; btemp[j][5]=b[j][5]; b[j][0]=b[j+1][0]; b[j][1]=b[j+1][1]; b[j][2]=b[j+1][2]; b[j][3]=b[j+1][3]; b[j][4]=b[j+1][4]; b[j][5]=b[j+1][5]; b[j+1][0]=btemp[j][0]; b[j+1][1]=btemp[j][1]; b[j+1][2]=btemp[j][2]; b[j+1][3]=btemp[j][3]; b[j+1][4]=btemp[j][4]; b[j+1][5]=btemp[j][5]; } } } for(j=0;j<T;j++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",b[j][0],b[j][1],b[j][2],b[j][3],b[j][4],b[j][5],c[j]); } }
64
31756
int main() { int n,i,j,r,t; float x[10],y[10],z[10],d[10][10]={-1},max; 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++) 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])); for (int k=0;k<(n*(n-1)/2);k++) { max=0; for (i=0;i<n;i++) for (j=i+1;j<n;j++) if (d[i][j]>max) { max=d[i][j]; r=i; t=j; } d[r][t]=-1; cout<<'('<<x[r]<<','<<y[r]<<','<<z[r]<<")-("<<x[t]<<','<<y[t]<<','<<z[t]<<")="; printf("%.2f\n",max); } return 0; }
64
31757
int main(){ int n,a[11],b[11],c[11],i,j,s,q,maxi=0,maxj=1; double d[90][90]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); } for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ s=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]); d[i][j]=sqrt(1.0*s); } } for(q=0;q<n*(n-1)/2;q++){ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(d[i][j]>d[maxi][maxj]){ maxi=i; maxj=j; } } } printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[maxi],b[maxi],c[maxi],a[maxj],b[maxj],c[maxj],d[maxi][maxj]); d[maxi][maxj]=0; } return 0; }
64
31758
void main() { int n,i,m,j,k=0; double d,b[100][7]={0},a[10][3]={0},temp[7]; char c[10][3]; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<3;j++) { scanf("%lf",&a[i][j]); scanf("%c",&c[i][j]); } } for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])); b[k][0]=a[i][0]; b[k][1]=a[i][1]; b[k][2]=a[i][2]; b[k][3]=a[j][0]; b[k][4]=a[j][1]; b[k][5]=a[j][2]; b[k][6]=d; k++; } } for(i=0;i<n*(n-1)/2;i++) { for(j=i+1;j<n*(n-1)/2;j++) { if(b[j][6]>b[i][6]) { for(k=0;k<7;k++) { temp[k]=b[j][k]; } for(m=j;m>i;m--) { for(k=0;k<7;k++) { b[m][k]=b[m-1][k]; } } for(k=0;k<7;k++) { b[i][k]=temp[k]; } } } } for(i=0;i<n*(n-1)/2;i++) printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",b[i][0],b[i][1],b[i][2],b[i][3],b[i][4],b[i][5],b[i][6]); }
64
31759
int main() { int n,i,j,k=0; int x[10],y[10],z[10]; struct Distance { int a,b; double d; }dis[50],t; scanf("%d",&n); for(i=0;i<=n-1;i++) scanf("%d %d %d",&x[i],&y[i],&z[i]); for(i=0;i<=n-1;i++) for(j=1+i;j<=n-1;j++) { if(i==j) continue; dis[k].d=sqrt((double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))); dis[k].a=i; dis[k].b=j; k++; } for(i=0;i<=k-2;i++) for(j=0;j<=k-2-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-1;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[dis[i].a],y[dis[i].a],z[dis[i].a],x[dis[i].b],y[dis[i].b],z[dis[i].b],dis[i].d); return 0; }
64
31760
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
31761
int main() { struct { double x; double y; double z; }point[15]; struct stru { int p,q; double distance; }dis[50],temp; int n,i,j; cin>>n; for(i=0;i<n;i++) cin>>point[i].x>>point[i].y>>point[i].z; int k=0; for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { dis[k].p=i;dis[k].q=j; double a,b,c; a=(point[i].x-point[j].x)*(point[i].x-point[j].x); b=(point[i].y-point[j].y)*(point[i].y-point[j].y); c=(point[i].z-point[j].z)*(point[i].z-point[j].z); dis[k].distance=sqrt(a+b+c); k=k+1; } for(i=1;i<=k;i++) for(j=0;j<k-i;j++) { if(dis[j].distance<dis[j+1].distance) { temp=dis[j];dis[j]=dis[j+1];dis[j+1]=temp; } } for(i=0;i<=k-1;i++) { cout<<'('<<point[dis[i].p].x<<','<<point[dis[i].p].y<<','<<point[dis[i].p].z<<')'; cout<<"-("<<point[dis[i].q].x<<','<<point[dis[i].q].y<<','<<point[dis[i].q].z<<")="; printf("%.2f\n",dis[i].distance); } return 0; }
64
31762
int main() { int n, i, j, k, l, m, a, b; int x[12] = {0}; int y[12] = {0}; int z[12] = {0}; double d[12][12] = {0}; double max; int pm[12][12] = {0}; cin >> n; for (i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> z[i]; } for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { d[i][j] = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j])); } } max = -1.0; k = n * (n - 1) / 2; for (l = 1; l <= k; l++) { for (i = 1; i <= n; i++) { for (j = i + 1; j <= n; j++) { if (d[i][j] - max > 1e-10) { max = d[i][j]; a = i; b = j; } } } cout << "(" << x[a] << "," << y[a] << "," << z[a] << ")" << "-" << "(" << x[b] << "," << y[b] << "," << z[b] << ")" << "=" << fixed << setprecision(2) << d[a][b] << endl; d[a][b] = 0; max = - 1; } return 0; }
64
31763
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
31764
struct dis { int place_p1; int p1[3]; int place_p2; int p2[3]; float distance; }p[45]; void main() { void exchange(struct dis *pa,struct dis *pb); int n,i,j,point[10][3],count=0; struct dis *po=p; 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-1;i++) for(j=i+1;j<n;j++) { po->place_p1=i; po->p1[0]=point[i][0]; po->p1[1]=point[i][1]; po->p1[2]=point[i][2]; po->place_p2=j; po->p2[0]=point[j][0]; po->p2[1]=point[j][1]; po->p2[2]=point[j][2]; float d1,d2,d3; d1=(float)point[i][0]-point[j][0]; d2=(float)point[i][1]-point[j][1]; d3=(float)point[i][2]-point[j][2]; po->distance=sqrt(d1*d1+d2*d2+d3*d3); po++; } for(i=0;i<n*(n-1)/2;i++) for(j=0;j<n*(n-1)/2;j++) if(p[j].distance<p[j+1].distance) exchange(&p[j],&p[j+1]); for(i=0,po=p;i<n*(n-1)/2;i++,po++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",po->p1[0],po->p1[1],po->p1[2],po->p2[0],po->p2[1],po->p2[2],po->distance); } void exchange(struct dis *pa,struct dis *pb) { float temp;int i; int t; t=pa->place_p1;pa->place_p1=pb->place_p1;pb->place_p1=t; t=pa->place_p2;pa->place_p2=pb->place_p2;pb->place_p2=t; for(i=0;i<3;i++) { t=pa->p1[i];pa->p1[i]=pb->p1[i];pb->p1[i]=t; t=pa->p2[i];pa->p2[i]=pb->p2[i];pb->p2[i]=t; } temp=pa->distance; pa->distance=pb->distance; pb->distance=temp; }
64
31765
//********************************** //**** ?????? ***** //**** 1200012718 ***** //** ??????? ** //********************************** int main() { int n; cin>>n; //????n int x[11]={0},y[11]={0},z[11]={0}; //??????xyz????????????? double x1[11]={0},y1[11]={0},z1[11]={0}; //????? double d[46]={0}; //d??????10????45??? int begin[46]={0},end[46]={0}; //?????????????? for (int i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i]; x1[i]=x[i]; y1[i]=y[i]; z1[i]=z[i]; } //?????????? int k=1; //???k?????d?????????? for (int i=1;i<=n;i++) for (int j=i+1;j<=n;j++) { d[k]=sqrt((x1[i]-x1[j])*(x1[i]-x1[j])+(y1[i]-y1[j])*(y1[i]-y1[j])+(z1[i]-z1[j])*(z1[i]-z1[j])); begin[k]=i; end[k]=j; k++; } //???????begin end?????? for (int i=1;i<=n*(n-1)/2-1;i++) //???? for (int j=1;j<=n*(n-1)/2-i;j++) { if (d[j]<d[j+1]) { double m=d[j]; d[j]=d[j+1]; d[j+1]=m; //?????????????????????? int t=begin[j]; begin[j]=begin[j+1]; begin[j+1]=t; t=end[j]; end[j]=end[j+1]; end[j+1]=t; } } for(int i=1;i<=n*(n-1)/2;i++) { cout<<"("<<x[begin[i]]<<","<<y[begin[i]]<<","<<z[begin[i]]<<")-("<<x[end[i]]<<","<<y[end[i]]<<","<<z[end[i]]<<")="; printf("%.2f\n",d[i]);//????? } return 0; }
64
31766
//**************************************** //*???? ** //*??? 1100012927 ** //*2011.11.29 ** //**************************************** int main() { int n, i, j, k, z = 0; double dis[50][7], zb[10][3], temp; double (*p)[7]; p = dis; cin >> n; for (i = 0; i < n; i++) { cin >> zb[i][0] >> zb[i][1] >> zb[i][2]; } for (i = 0; i < n - 1; i++) for (j = i + 1; j < n; j++) { for (k = 0; k < 3; k++) { *(*(p + z) + k) = zb[i][k]; *(*(p + z) + k + 3) = zb[j][k]; } *(*(p + z) + 6) = sqrt(pow((*(*(p + z) + 0) - *(*(p + z) + 3)), 2) + pow((*(*(p + z) + 1) - *(*(p + z) + 4)), 2) + pow((*(*(p + z) + 2)- *(*(p + z) + 5)), 2)); z++; } for (i = 0; i < z - 1; i++) for (j = 0; j < z - i - 1; j++) { if (fabs(*(*(p + j) + 6) - *(*(p + j + 1) + 6)) < 1e-3) continue; else if (*(*(p + j) + 6) < *(*(p + j + 1) + 6)) { for (k = 0; k < 7; k++) { temp = *(*(p + j) + k); *(*(p + j) + k) = *(*(p + j + 1) + k); *(*(p + j + 1) + k) = temp; } } } for (i = 0; i < n * (n - 1) / 2; i++) { cout << fixed; cout <<setprecision(0)<< "(" << *(*(p + i) + 0) <<","<< *(*(p + i) + 1) <<"," << *(*(p + i) + 2) <<")-("<< *(*(p + i) + 3) <<","<<*(*(p + i) + 4)<<","<<*(*(p + i) + 5)<<")="; cout << setprecision(2) << *(*(p + i) + 6)<<endl; } return 0; }
64
31767
int main(){ int i,j,k,m,n; double e; scanf("%d",&n); int sz[10][3]; for(i=0;i<n;i++){ for(j=0;j<3;j++){ scanf("%d",&sz[i][j]); } } double s[50]; m=0; double zong; int a[50][3]; int b[50][3]; for(j=0;j<(n-1);j++){ for(i=j+1;i<=n-1;i++){ zong=0; for(k=0;k<3;k++){ a[m][k]=sz[j][k]; b[m][k]=sz[i][k]; zong+=pow((a[m][k]-b[m][k]),2); } s[m]=sqrt(zong); m++; } } for(j=0;j<m-1;j++){ for(i=0;i<m-1-j;i++){ if(s[i]<s[i+1]){ e=s[i]; s[i]=s[i+1]; s[i+1]=e; for(k=0;k<3;k++){ e=a[i][k]; a[i][k]=a[i+1][k]; a[i+1][k]=e; e=b[i][k]; b[i][k]=b[i+1][k]; b[i+1][k]=e; } } } } for(i=0;i<m;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i][0],a[i][1],a[i][2],b[i][0],b[i][1],b[i][2],s[i]); } return 0; }
64
31768
int main() { struct distance { int x; int y; double l; }; struct distance d[100]; int n,i,k,mount,tx,ty,j; int a[11][4]; double s[11][11]; double t,tl; scanf("%d",&n); for(i=1;i<=n;i++) { scanf("%d%d%d",&a[i][1],&a[i][2],&a[i][3]); } k=1; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { t=(double)((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3])); s[i][j]=sqrt(t); d[k].l=s[i][j]; d[k].x=i; d[k].y=j; k++; } } mount=n*(n-1)/2; if(mount>=2) { for(i=1;i<=mount-1;i++) { for(j=mount-1;j>=i;j--) { if(d[j].l<d[j+1].l) { tx=d[j].x; ty=d[j].y; tl=d[j].l; d[j].x=d[j+1].x; d[j].y=d[j+1].y; d[j].l=d[j+1].l; d[j+1].x=tx; d[j+1].y=ty; d[j+1].l=tl; } } } } for(i=1;i<=mount;i++) { tx=d[i].x; ty=d[i].y; tl=d[i].l; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[tx][1],a[tx][2],a[tx][3],a[ty][1],a[ty][2],a[ty][3],tl); } return 0; }
64
31769
int main () { int n; int a[10][3]; double d[45][3]; int i=0; double change; cin>>n; for (int t=0;t<n;++t) cin>>a[t][0]>>a[t][1]>>a[t][2]; for (int t1=0;t1<n;++t1) for (int t2=t1+1;t2<n;++t2) { d[i][0]=t1; d[i][1]=t2; d[i][2]=sqrt( (a[t1][0]-a[t2][0])*(a[t1][0]-a[t2][0]) + (a[t1][1]-a[t2][1])*(a[t1][1]-a[t2][1]) + (a[t1][2]-a[t2][2])*(a[t1][2]-a[t2][2]) ); ++i; } for (int t1=0;t1<i-1;++t1) for (int t2=0;t2<i-1-t1;++t2) if (d[t2][2]<d[t2+1][2]) { change=d[t2][2]; d[t2][2]=d[t2+1][2]; d[t2+1][2]=change; change=d[t2][0]; d[t2][0]=d[t2+1][0]; d[t2+1][0]=change; change=d[t2][1]; d[t2][1]=d[t2+1][1]; d[t2+1][1]=change; } for (int t=0;t<i;++t) printf ("(%d,%d,%d)-(%d,%d,%d)=%0.2lf\n",a[(int) d[t][0]][0],a[(int) d[t][0]][1], a[(int) d[t][0]][2],a[(int) d[t][1]][0],a[(int) d[t][1]][1],a[(int) d[t][1]][2],d[t][2]); return 0; }
64
31770
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
31771
int main() { int n,m=0; int i=0,j=0; int a=0,b=0; double i1=0; int i2=0,i3=0,i4=0,i5=0; double x[10],y[10],z[10],distance[100]; int p[100],q[100],p1[100],q1[100]; cin>>n; for(m=0;m<n;m++) cin>>x[m]>>y[m]>>z[m]; for(i=0;i<100;i++) { p[i]=0; q[i]=0; } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { distance[b]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); p[b]=i; q[b]=j; //cout<<p[b]<<q[b]; b++; } } i4=0; i5=0; for(i4=0;i4<n*(n-1)/2-1;i4++) { for(i5=i4+1;i5<n*(n-1)/2;i5++) { if(distance[i5]>distance[i4]) { i1=distance[i4]; distance[i4]=distance[i5]; distance[i5]=i1; i2=p[i4]; p[i4]=p[i5]; p[i5]=i2; i3=q[i4]; q[i4]=q[i5]; q[i5]=i3; } } } i=0; for(i=0;i<n*(n-1)/2;i++) { if(distance[i]==distance[i+1]) { if(p[i]>p[i+1]) { i2=p[i+1]; p[i+1]=p[i]; p[i]=i2; i3=q[i+1]; q[i+1]=q[i]; q[i]=i3; } if(p[i]==p[i+1]&&q[i]>q[i+1]) { i2=p[i+1]; p[i+1]=p[i]; p[i]=i2; i3=q[i+1]; q[i+1]=q[i]; q[i]=i3; } } } for(i=0;i<n*(n-1)/2;i++) { cout<<"("<<x[p[i]]<<","<<y[p[i]]<<","<<z[p[i]]<<")"<<"-("<<x[q[i]]<<","<<y[q[i]]<<","<<z[q[i]]<<")="; printf("%.2lf\n",distance[i]); } return 0; }
64
31772
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
31773
int main(){ int n,m,t,i,j,x[15],y[15],z[15]; double s[150],k; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } t=0; for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ s[t]=sqrt((1.0)*((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))); t++; } } for(i=1;i<=t-1;i++){ for(j=0;j<t-i;j++){ if(s[j]<s[j+1]){ k=s[j]; s[j]=s[j+1]; s[j+1]=k; } } } for(m=0;m<t;m++){ if(s[m]==s[m+1]){ continue; }else{ for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(s[m]==sqrt((1.0)*(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],s[m]); } } } } } return 0; }
64
31774
int main() { int n,a[10],b[10],c[10],i,j,x,m=0; double sun[10][10],s[50],k; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&a[i],&b[i],&c[i]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ sun[i][j]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); } } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ s[m]=sun[i][j]; m++; } } for(i=0;i<m;i++){ for(j=i+1;j<m;j++){ if(s[j]>s[i]){ k=s[i]; s[i]=s[j]; s[j]=k; } } } for(i=0;i<m;i++){ if(s[i]==s[i+1]){ for(j=i+1;j<m;j++){ s[j]=s[j+1]; i=i-1; m=m-1; } } } for(x=0;x<m;x++){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ if(s[x]==sun[i][j]){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],a[j],b[j],c[j],sun[i][j]); } } } } return 0; }
64
31775
struct point{ int x; int y; int z; }point[10]; struct jl{ int c; int d; float f; }jl[45]; int main() { int n,i,j; struct jl t; float juli(struct point a,struct point b); scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].z); for(i=0;i<n-1;i++) for(j=i+1;j<n;j++){ jl[n*i-i*(i+1)/2+j-i-1].f=juli(point[i],point[j]); jl[n*i-i*(i+1)/2+j-i-1].c=i; jl[n*i-i*(i+1)/2+j-i-1].d=j; } for(j=1;j<n*(n-1)/2;j++) for(i=0;i<n*(n-1)/2-j;i++) if(jl[i].f<jl[i+1].f){ t=jl[i]; jl[i]=jl[i+1]; jl[i+1]=t; } for(i=0;i<n*(n-1)/2;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",point[jl[i].c].x,point[jl[i].c].y,point[jl[i].c].z,point[jl[i].d].x,point[jl[i].d].y,point[jl[i].d].z,jl[i].f); return 0; } float juli(struct point a,struct point b) { float k; k=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z)); return k; }
64
31776
int main(){ int n,h[10],z[10],s[10],a[100],b[100],c[100],d[100],e[100],f[100],i,j,l,m,o,q,r,t,k; double g[100],p; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&h[i],&z[i],&s[i]); } k=0; for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ g[k]=pow((h[i]-h[j])*(h[i]-h[j])+(z[i]-z[j])*(z[i]-z[j])+(s[i]-s[j])*(s[i]-s[j]),0.5); a[k]=h[i]; b[k]=z[i]; c[k]=s[i]; d[k]=h[j]; e[k]=z[j]; f[k]=s[j]; k++; } } for(k=0;k<n*(n-1)/2;k++){ for(i=0;i<n*(n-1)/2-k;i++){ if(g[i]<g[i+1]){ p=g[i]; g[i]=g[i+1]; g[i+1]=p; l=a[i]; a[i]=a[i+1]; a[i+1]=l; m=b[i]; b[i]=b[i+1]; b[i+1]=m; o=c[i]; c[i]=c[i+1]; c[i+1]=o; q=d[i]; d[i]=d[i+1]; d[i+1]=q; r=e[i]; e[i]=e[i+1]; e[i+1]=r; t=f[i]; f[i]=f[i+1]; f[i+1]=t; } } } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],d[i],e[i],f[i],g[i]); } return 0; }
64
31777
int main() { int n,j,t,a,b,r=0,x[10],y[10],z[10]; double e,sz[45][3]; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(j=0;j<n-1;j++){ for(t=j+1;t<n;t++){ sz[r][0]=j; sz[r][1]=t; sz[r][2]=sqrt((x[j]-x[t])*(x[j]-x[t])+(y[j]-y[t])*(y[j]-y[t])+(z[j]-z[t])*(z[j]-z[t])); r++; } } for(j=1;j<=r;j++){ for(t=0;t<r-j;t++){ if(sz[t][2]<sz[t+1][2]){ e=sz[t][2]; sz[t][2]=sz[t+1][2]; sz[t+1][2]=e; e=sz[t][0]; sz[t][0]=sz[t+1][0]; sz[t+1][0]=e; e=sz[t][1]; sz[t][1]=sz[t+1][1]; sz[t+1][1]=e; } } } for(j=0;j<r;j++){ int a=sz[j][0]; int b=sz[j][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a],y[a],z[a],x[b],y[b],z[b],sz[j][2]); } return 0; }
64
31778
int main() { int n,x[20],y[20],z[20],i,j,q,w,k; double dis[20][20]={0},max; scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d %d %d",&x[i],&y[i],&z[i]); for (i=1;i<n;i++) for (j=i+1;j<=n;j++) dis[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])); for (i=1;i<=((n*(n-1))/2);i++){ max=0; for (j=1;j<n;j++) for (k=j+1;k<=n;k++) if (dis[j][k]>max){ max=dis[j][k]; q=j; w=k; } printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[q],y[q],z[q],x[w],y[w],z[w],dis[q][w]); dis[q][w]=0; } return 0; }
64
31779
int main(){ int n,i,j,m,k=0,x[10],y[10],z[10],a[50],b[50]; double d[50],e; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i],&y[i],&z[i]); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a[k]=i; b[k]=j; d[k]=sqrt(1.0*(x[i]-x[j])*(x[i]-x[j])+1.0*(y[i]-y[j])*(y[i]-y[j])+1.0*(z[i]-z[j])*(z[i]-z[j])); k++; } } for(i=k;i>0;i--){ for(j=k-1;j>0;j--){ if(d[j]>d[j-1]){ e=d[j]; d[j]=d[j-1]; d[j-1]=e; m=a[j]; a[j]=a[j-1]; a[j-1]=m; m=b[j]; b[j]=b[j-1]; b[j-1]=m; } } } for(i=0;i<k;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],d[i]); } return 0; }
64
31780
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
31781
int main(){ int n=0; cin>>n; int dis[10][3]; float ans[1000][7]; for(int i=0;i<n;i++){ for(int j=0;j<3;j++){ cin>>dis[i][j]; } } int num=0; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ for(int k=0;k<3;k++){ ans[num][k]=dis[i][k]; } for(int k=0;k<3;k++){ ans[num][k+3]=dis[j][k]; } ans[num][6]=0.0; for(int k=0;k<3;k++){ ans[num][6]+=(dis[i][k]-dis[j][k])*(dis[i][k]-dis[j][k]); } ans[num][6]=sqrt(ans[num][6]); num++; } } for(int i=0;i<num;i++){ for(int j=num-1;j>i;j--){ if(ans[j][6]>ans[j-1][6]){ for(int k=0;k<7;k++){ float tmp=ans[j][k]; ans[j][k]=ans[j-1][k]; ans[j-1][k]=tmp; } } } } for(int i=0;i<num;i++){ cout<<'('<<ans[i][0]<<','<<ans[i][1]<<','<<ans[i][2]<<")-("<<ans[i][3]<<','<<ans[i][4]<<','<<ans[i][5]<<")="; printf("%.2f",ans[i][6]); if(i<num-1) cout<<endl; } return 0; }
64
31782
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
31783
int main() { int n; scanf("%d",&n); double x[150],y[150],z[150]; int i; for(i=1;i<=n;i++) { scanf("%lf",&x[i]); scanf("%lf",&y[i]); scanf("%lf",&z[i]); } int j,h; h=1; double sum; double s1[150][150]; double a[10000]; for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { sum=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]); s1[i][j]=sqrt(sum); a[h]=s1[i][j]; h++; } } h--; int k; double e; for(k=1;k<h;k++) { for(i=1;i<=h-k;i++) { if(a[i]<a[i+1]) { e=a[i]; a[i]=a[i+1]; a[i+1]=e; } } } int count=2; double b[10000]; b[1]=a[1]; for(i=2;i<=h;i++) { if(a[i]!=a[i-1]) { b[count]=a[i]; count++; } } count--; for(k=1;k<=count;k++) { for(i=1;i<n;i++) { for(j=i+1;j<=n;j++) { if(s1[i][j]==b[k]) printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],b[k]); } } } return 0; }
64
31784
int main(){ int n,i; scanf("%d",&n); int sz[30]; for(i=0;i<(3*n);i++){ scanf("%d",&sz[i]); } double dd[10][10]; int j,k; for(i=0;i<n;i++){ for(j=0;j<n;j++){ dd[i][j]=sqrt(1.0*((sz[3*i]-sz[3*j])*(sz[3*i]-sz[3*j])+(sz[3*i+1]-sz[3*j+1])*(sz[3*i+1]-sz[3*j+1])+(sz[3*i+2]-sz[3*j+2])*(sz[3*i+2]-sz[3*j+2]))); } } double xin[45]; int d,e; int di[45],dj[45]; double max=0; for(k=0;k<n*(n-1)/2;k++){ for(i=n-1;i>=0;i--){ for(j=n-1;j>=0;j--){ if(dd[i][j]>=max&&k==0&&i!=j){ di[k]=i; dj[k]=j; max=dd[i][j]; } if(dd[i][j]>=max&&k!=0&&i!=j){ di[k]=i; dj[k]=j; max=dd[i][j]; } } } dd[di[k]][dj[k]]=-1; dd[dj[k]][di[k]]=-1; xin[k]=max; max=0; } for(i=0;i<n*(n-1)/2;i++){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[3*di[i]],sz[3*di[i]+1],sz[3*di[i]+2],sz[3*dj[i]],sz[3*dj[i]+1],sz[3*dj[i]+2],xin[i]); } return 0; }
64
31785
int a[1001][1001],b[1001][1001],c[1001][1001]; double s[1000001][3]; struct { double x,y,z; }point[10001]; double dis(int i,int j)//???? { return sqrt((point[i].x-point[j].x)*(point[i].x-point[j].x)+ (point[i].y-point[j].y)*(point[i].y-point[j].y)+ (point[i].z-point[j].z)*(point[i].z-point[j].z)); } void change(int n)//??? { double temp; temp=s[n][0]; s[n][0]=s[n+1][0]; s[n+1][0]=temp; temp=s[n][1]; s[n][1]=s[n+1][1]; s[n+1][1]=temp; temp=s[n][2]; s[n][2]=s[n+1][2]; s[n+1][2]=temp; } void print (int n)//?? { int lt=(int)(s[n][1]),rt=(int)(s[n][2]); cout<<"("<<point[lt].x<<','<<point[lt].y<<','<<point[lt].z<<")"; cout<<'-'; cout<<"("<<point[rt].x<<','<<point[rt].y<<','<<point[rt].z<<")"; cout<<'='; printf("%.2f\n",s[n][0]); } void bubblesort(int k)//?? { int i,j; for(i=1;i<k;i++) for(j=1;j<=k-i;j++) if(s[j][0]<s[j+1][0]) change(j); } int main() { int n,m; cin>>n; int i,j,k; for(i=1;i<=n;i++) cin>>point[i].x>>point[i].y>>point[i].z; k=1; for(i=1;i<=n;i++) for(j=i+1;j<=n;j++){ s[k][0]=dis(i,j); s[k][1]=i; s[k][2]=j; k++; } k--; bubblesort(k); for(i=1;i<=k;i++) print(i); return 0; }
64
31786
int main(){ struct point{ int x,y,z; }points[10]; double d[45],e,a; int n,i,j,k=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d %d %d",&points[i].x,&points[i].y,&points[i].z); } for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=1.0*(points[i].x-points[j].x)*(points[i].x-points[j].x)+1.0*(points[i].y-points[j].y)*(points[i].y-points[j].y)+1.0*(points[i].z-points[j].z)*(points[i].z-points[j].z); d[k]=sqrt(a); k++; } } for(k=0;k<n*(n-1)/2;k++){ for(i=0;i<n*(n-1)/2-1-k;i++){ if(d[i]<d[i+1]){ e=d[i+1]; d[i+1]=d[i]; d[i]=e; } } } for(k=1;k<n*(n-1)/2;k++){ if(d[k]==d[k-1]){ d[k-1]=0; } } for(int b=0;b<n*(n-1)/2;b++){ for(i=0;i<n;i++){ for(j=i+1;j<n;j++){ a=1.0*(points[i].x-points[j].x)*(points[i].x-points[j].x)+1.0*(points[i].y-points[j].y)*(points[i].y-points[j].y)+1.0*(points[i].z-points[j].z)*(points[i].z-points[j].z); e=sqrt(a); if(d[b]==e){ printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",points[i].x,points[i].y,points[i].z,points[j].x,points[j].y,points[j].z,d[b]); } } } } return 0; }
64
31787
/* *????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
31788
int main() { int n,i,j,k=0,l; double a[102][4],b[102][102],c[2000]={0}; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=3;j++) { cin>>a[i][j]; } } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { b[i][j]=sqrt((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][3]-a[j][3])*(a[i][3]-a[j][3])); c[k]=b[i][j]; k++; } } sort(c,c+n*(n-1)/2); for(k=n*(n-1)/2-1;k>=0;k--) {if(c[k+1]==c[k])continue; for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { if(b[i][j]==c[k]) {cout<<"("<<a[i][1]<<","<<a[i][2]<<","<<a[i][3]<<")-("<<a[j][1]<<","<<a[j][2]<<","<<a[j][3]<<")="; printf("%.2f",c[k]); cout<<endl;} } } } return 0; }
64
31789
int main() { int n,a[200],b[200],c[200],i,j,h[200],l[200],t=1,q,z; double d[200],k; cin>>n; for(i=1;i<=n;i++) { cin>>a[i]>>b[i]>>c[i]; } for(i=1;i<=n-1;i++) { for(j=i+1;j<=n;j++) { d[t]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j])); h[t]=i; l[t]=j; t++; } } for(i=1;i<=n*(n-1)/2-1;i++) { for(j=1;j<=n*(n-1)/2-i;j++) { if(d[j]<d[j+1]) { k=d[j]; d[j]=d[j+1]; d[j+1]=k; z=h[j]; h[j]=h[j+1]; h[j+1]=z; z=l[j]; l[j]=l[j+1]; l[j+1]=z; } } } for(i=1;i<=n*(n-1)/2;i++) { cout<<"("<<a[h[i]]<<","<<b[h[i]]<<","<<c[h[i]]<<")-("<<a[l[i]]<<","<<b[l[i]]<<","<<c[l[i]]<<")="; printf("%.2f\n",d[i]); } cin>>q; return 0; }
64
31790
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
31791
int main() { int n,t,i,j,k,x[110],y[110],z[110],a[500],aa[500],b[500],bb[500],c[500],cc[500],l; double s[110],ty; scanf("%d",&n); k=0; for (i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for (i=0;i<n-1;i++) for(j=i+1;j<n;j++) { s[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]=(x[i]); b[k]=(y[i]); c[k]=(z[i]); aa[k]=(x[j]); bb[k]=(y[j]); cc[k]=(z[j]); k++; } for (i=k-1;i>0;i--) for(j=0;j<i;j++) if (s[j+1]>s[j]) { ty=s[j+1]; s[j+1]=s[j]; s[j]=ty; t=a[j+1]; a[j+1]=a[j]; a[j]=t; t=b[j+1]; b[j+1]=b[j]; b[j]=t; t=c[j+1]; c[j+1]=c[j]; c[j]=t; t=aa[j+1]; aa[j+1]=aa[j]; aa[j]=t; t=bb[j+1]; bb[j+1]=bb[j]; bb[j]=t; t=cc[j+1]; cc[j+1]=cc[j]; cc[j]=t; } for (i=0;i<k;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i],b[i],c[i],aa[i],bb[i],cc[i],s[i]); return 0; }
64
31792
float dist(int a,int b,int c,int a1,int b1,int c1); int toi(int fi,int ni); int toj(int fj,int nj); int main() { int x[10],y[10],z[10]; int n,i,j,o=1,flag,ansi,ansj; float d[46]; float max; scanf("%d",&n); for(i=0;i<n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { d[o]=dist(x[i],y[i],z[i],x[j],y[j],z[j]); o++; } } for(i=1;i<o;i++) { max=0; for(j=1;j<o;j++) { if(d[j]>max) { max=d[j]; flag=j; } else continue; } ansi=toi(flag,n); ansj=toj(flag,n); printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[ansi],y[ansi],z[ansi],x[ansj],y[ansj],z[ansj],max); d[flag]=0; } return 0; } float dist(int a,int b,int c,int a1,int b1,int c1) { float D; D=sqrt((a-a1)*(a-a1)+(b-b1)*(b-b1)+(c-c1)*(c-c1)); return(D); } int toi(int fi,int ni) { int ai,testfi,qi; testfi=fi; qi=1; do { if(testfi-(ni-qi)<=0) { ai=qi-1; break; } else { testfi-=ni-qi; qi++; } }while(qi<ni); return(ai); } int toj(int fj,int nj) { int aj,testfj,qj; testfj=fj; qj=1; do { if(testfj-(nj-qj)<=0) { aj=testfj+qj-1; break; } else { testfj-=nj-qj; qj++; } }while(qj<nj); return(aj); }
64
31793
void main() { int n,i,j,t,l=0; int x[20],y[20],z[20],d1[100],d2[100]; float d[100],temp; scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d%d%d",&x[i],&y[i],&z[i]); for (i=1;i<n;i++) for (j=i+1;j<=n;j++) { l++; d[l]=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])); d1[l]=i;d2[l]=j; } for (i=1;i<n*(n-1)/2;i++) for (j=1;j<n*(n-1)/2;j++) if (d[j]<d[j+1]) {temp=d[j];d[j]=d[j+1];d[j+1]=temp; t=d1[j];d1[j]=d1[j+1];d1[j+1]=t; t=d2[j];d2[j]=d2[j+1];d2[j+1]=t;} for (i=1;i<=n*(n-1)/2;i++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[d1[i]],y[d1[i]],z[d1[i]],x[d2[i]],y[d2[i]],z[d2[i]],d[i]); }
64
31794
int main() { struct sanwei { int x; int y; int z; }room[10]; int n, i, j; double dis[100]; 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] = ((x1[k] - x2[k]) * (x1[k] - x2[k]) + (y1[k] - y2[k]) * (y1[k] - y2[k]) + (z1[k] - z2[k]) * (z1[k] - z2[k])); dis[k] = sqrt(dis[k]); k++; } double temp; 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
31795
int main() { int n,a[10][3],i,j,d[45][2][2],k=0,c,x,y; double z; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]); } for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { d[k][0][0]=i; d[k][0][1]=j; d[k][1][1]=(a[i][0]-a[j][0])*(a[i][0]-a[j][0]) +(a[i][1]-a[j][1])*(a[i][1]-a[j][1]) +(a[i][2]-a[j][2])*(a[i][2]-a[j][2]); k++; } } for(i=0;i<n*(n-1)/2-1;i++) { for(j=0;j<n*(n-1)/2-i-1;j++) { if(d[j][1][1]<d[j+1][1][1]) { c=d[j][0][0]; d[j][0][0]=d[j+1][0][0]; d[j+1][0][0]=c; c=d[j][0][1]; d[j][0][1]=d[j+1][0][1]; d[j+1][0][1]=c; c=d[j][1][1]; d[j][1][1]=d[j+1][1][1]; d[j+1][1][1]=c; } } } for(i=0;i<n*(n-1)/2;i++) { z=sqrt(d[i][1][1]*1.0); x=d[i][0][0]; y=d[i][0][1]; printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", a[x][0],a[x][1],a[x][2] ,a[y][0],a[y][1],a[y][2] ,z); } return 0; }
64
31796
int main() { int n; cin>>n; int i,j,k,r,t; double s; int x[11],y[11],z[11]; for(i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i]; } double w[100]; int p[100],q[100]; i = 1; int d=n*(n-1)/2; for(j = 1;j < n;j++) { for (k = j+1;k<= n;k++) { w[i]=sqrt(pow((x[j]-x[k]),2.0)+pow((y[j]-y[k]),2.0)+pow((z[j]-z[k]),2.0)); p[i]=j; q[i]=k; i++; } } for(j=1;j<d;j++) { for(i=1;i<=d-j;i++) { if(w[i]<w[i+1]) { s=w[i]; w[i]=w[i+1]; w[i+1]=s; r=p[i]; p[i]=p[i+1]; p[i+1]=r; t=q[i]; q[i]=q[i+1]; q[i+1]=t; } } } for(i=1;i<=d;i++) cout<<"("<<x[p[i]]<<","<<y[p[i]]<<","<<z[p[i]]<<")-"<<"("<<x[q[i]]<<","<<y[q[i]]<<","<<z[q[i]]<<")="<<fixed<<setprecision(2)<<w[i]<<endl; return 0; }
64
31797
double distance(int x1, int y1, int z1, int x2, int y2, int z2){ double q,s; q=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2); s=sqrt(q); return s; } int main(){ int n,k,i,j,x[10],y[10],z[10]; double sz[46][7]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d%d%d",&x[i], &y[i], &z[i]); } k=0; for(i=0;i<n-1;i++){ for(j=i;j<n-1;j++){ sz[k][0]=x[i]*1.0; sz[k][1]=y[i]*1.0; sz[k][2]=z[i]*1.0; sz[k][3]=x[j+1]*1.0; sz[k][4]=y[j+1]*1.0; sz[k][5]=z[j+1]*1.0; sz[k][6]=distance(x[i],y[i],z[i],x[j+1],y[j+1],z[j+1]); k++; } } for(i=0;i<k-1;i++){ for(j=0;j<k-i-1;j++){ if(sz[j][6]<sz[j+1][6]){ sz[45][0]=sz[j+1][0]; sz[45][1]=sz[j+1][1]; sz[45][2]=sz[j+1][2]; sz[45][3]=sz[j+1][3]; sz[45][4]=sz[j+1][4]; sz[45][5]=sz[j+1][5]; sz[45][6]=sz[j+1][6]; sz[j+1][0]=sz[j][0]; sz[j+1][1]=sz[j][1]; sz[j+1][2]=sz[j][2]; sz[j+1][3]=sz[j][3]; sz[j+1][4]=sz[j][4]; sz[j+1][5]=sz[j][5]; sz[j+1][6]=sz[j][6]; sz[j][0]=sz[45][0]; sz[j][1]=sz[45][1]; sz[j][2]=sz[45][2]; sz[j][3]=sz[45][3]; sz[j][4]=sz[45][4]; sz[j][5]=sz[45][5]; sz[j][6]=sz[45][6]; } } } for(i=0;i<k;i++){ printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",sz[i][0], sz[i][1], sz[i][2], sz[i][3], sz[i][4], sz[i][5], sz[i][6]); } return 0; }
64
31798
int main() { int i,j,n,x[10],y[10],z[10],xc,yc,zc,k=0,x1s[55],y1s[55],z1s[55],x2s[55],y2s[55],z2s[55]; double e,s[55]; scanf("%d\n",&n); for(i=0;i<n;i++) { scanf("%d",&x[i]); scanf("%d",&y[i]); scanf("%d",&z[i]); } for(i=0;i<n-1;i++) for(j=i+1;j<n;j++) { xc=x[i]-x[j]; yc=y[i]-y[j]; zc=z[i]-z[j]; s[k]=sqrt(xc*xc+yc*yc+zc*zc); x1s[k]=x[i]; x2s[k]=x[j]; y1s[k]=y[i]; y2s[k]=y[j]; z1s[k]=z[i]; z2s[k]=z[j]; k++; } for(j=n*(n-1)/2-1;j>0;j--) for(i=0;i<j;i++) if(s[i]<s[i+1]) { e=s[i]; s[i]=s[i+1]; s[i+1]=e; e=x1s[i]; x1s[i]=x1s[i+1]; x1s[i+1]=e; e=y1s[i]; y1s[i]=y1s[i+1]; y1s[i+1]=e; e=z1s[i]; z1s[i]=z1s[i+1]; z1s[i+1]=e; e=x2s[i]; x2s[i]=x2s[i+1]; x2s[i+1]=e; e=y2s[i]; y2s[i]=y2s[i+1]; y2s[i+1]=e; e=z2s[i]; z2s[i]=z2s[i+1]; z2s[i+1]=e; } for(k=0;k<n*(n-1)/2;k++) printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x1s[k],y1s[k],z1s[k],x2s[k],y2s[k],z2s[k],s[k]); return 0; }
64
31799
void main() { int a[101],aa[101],aaa[101]; int b[101],bb[101],bbb[101]; int c[101],cc[101],ccc[101]; int i,j,k=0,n,t; double d [101]; double t2; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d%d%d",&a[i],&b[i],&c[i]); } for (i=0;i<n-1;i++) { for (j=0;j<n-i-1;j++) { d[k]=sqrt((a[i]-a[j+i+1])*(a[i]-a[j+i+1])+(b[i]-b[j+i+1])*(b[i]-b[j+i+1])+(c[i]-c[j+i+1])*(c[i]-c[j+i+1])); aa[k]=a[i]; bb[k]=b[i]; cc[k]=c[i]; aaa[k]=a[j+i+1]; bbb[k]=b[j+i+1]; ccc[k]=c[j+i+1]; k++; } } for (i=0;i<k;i++) { for (j=0;j<k-i-1;j++) { if (d[j]<d[j+1]) { t2=d[j]; d[j]=d[j+1]; d[j+1]=t2; t=aa[j]; aa[j]=aa[j+1]; aa[j+1]=t; t=bb[j]; bb[j]=bb[j+1]; bb[j+1]=t; t=cc[j]; cc[j]=cc[j+1]; cc[j+1]=t; t=aaa[j]; aaa[j]=aaa[j+1]; aaa[j+1]=t; t=bbb[j]; bbb[j]=bbb[j+1]; bbb[j+1]=t; t=ccc[j]; ccc[j]=ccc[j+1]; ccc[j+1]=t; } } } for (i=0;i<k;i++) { printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",aa[i],bb[i],cc[i],aaa[i],bbb[i],ccc[i],d[i]); } }