id
int32 0
32.5k
| code
stringlengths 95
8.4k
| label
stringclasses 65
values |
---|---|---|
31,900 | 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 |
31,901 | double juli(int a,int b,int c,int d,int e,int f)
{
double t;
t=sqrt((a-d)*(a-d)+(b-e)*(b-e)+(c-f)*(c-f));
return t;
}
int main()
{
int a[11],b[11],c[11],e[50],f[50],temp1;
double d[50],temp;
int n,i,j,t=0;
scanf("%d",&n);
for(i=0;i<=n-1;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
for(j=0;j<=n-2;j++)
{
for(i=j;i<=n-2;i++)
{
d[t]=juli(a[j],b[j],c[j],a[i+1],b[i+1],c[i+1]);
e[t]=j;
f[t]=i+1;
t++;
}
}
for(i=0;i<=n*(n-1)/2-2;i++)
{
for(j=0;j<=n*(n-1)/2-2-i;j++)
{
if(d[j]<d[j+1])
{
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
temp1=e[j];
e[j]=e[j+1];
e[j+1]=temp1;
temp1=f[j];
f[j]=f[j+1];
f[j+1]=temp1;
}
}
}
for(i=0;i<=n*(n-1)/2-1;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[e[i]],b[e[i]],c[e[i]],a[f[i]],b[f[i]],c[f[i]],d[i]);
}
return 0;
}
| 64 |
31,902 | int main()
{
int n,m,i,j,k=0;
int q,w;
int a[10000][4],c[10000],d[10000];
double b[10000],e;
scanf("%d",&n);
m=n*(n-1)/2;
for(i=0;i<n;i++)
{
scanf("%d",&a[i][0]);
scanf("%d",&a[i][1]);
scanf("%d",&a[i][2]);
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
b[k]=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2]));
c[k]=i;
d[k]=j;
k++;
}
}
for(j=1;j<m;j++)
{
for(i=0;i<m-j;i++)
{
if(b[i+1]>b[i])
{
e=b[i];b[i]=b[i+1];b[i+1]=e;
q=c[i];c[i]=c[i+1];c[i+1]=q;
w=d[i];d[i]=d[i+1];d[i+1]=w;
}
}
}
for(i=0;i<m;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[c[i]][0],a[c[i]][1],a[c[i]][2],a[d[i]][0],a[d[i]][1],a[d[i]][2],b[i]);
return 0;
} | 64 |
31,903 | struct point{
int a;
int b;
int c;
}p[10];
struct dis{
double d;
int i;
int j;
}di[60],x;
int main()
{int k,m,q,n,y;
double z;
scanf("%d",&n);
for(k=0;k<n;k++)
scanf("%d%d%d",&p[k].a,&p[k].b,&p[k].c);
k=0;
for(m=0;m<n;m++)
{q=m+1;
for(;q<n;q++)
{z=((double)p[q].a-(double)p[m].a)*((double)p[q].a-(double)p[m].a)+((double)p[q].b-(double)p[m].b)*((double)p[q].b-(double)p[m].b)+((double)p[q].c-(double)p[m].c)*((double)p[q].c-(double)p[m].c);
di[k].d=(double)sqrt((double)z);
di[k].i=m;
di[k].j=q;
k=k+1;}}
for(y=0;y<n*(n-1)/2-1;y++)
{for(k=0;k<n*(n-1)/2;k++){if(di[k+1].d>di[k].d)
{x=di[k];
di[k]=di[k+1];
di[k+1]=x;}}}
for(k=0;k<n*(n-1)/2;k++)
{printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",p[di[k].i].a,p[di[k].i].b,p[di[k].i].c,p[di[k].j].a,p[di[k].j].b,p[di[k].j].c,di[k].d);}
}
| 64 |
31,904 | 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));
cin>>p[i]->x>>p[i]->y>>p[i]->z;
}
} //??n?????
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;
cin>>n;
Point *p[15];
Input(p,n);
double a[60];
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++;
}
}
} //??????????????a?
int count=k; //??a????
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;
}
}
} //??a[]??
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++;
} //?????????????????????????
return 0;
} | 64 |
31,905 | 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 |
31,906 | struct space
{
float b;
int x;
int y;
}
juli[100],cache;
int main()
{
int a[10][3];
int i,j,k=0;
int n;
scanf("%d",&n);
scanf("%d %d %d",&a[0][0],&a[0][1],&a[0][2]);
for(i=1;i<n;i++)
{
scanf(" %d %d %d",&a[i][0],&a[i][1],&a[i][2]);
}
for(i=0,j=0;;)
{
juli[k].x=i;juli[k].y=j;
juli[k].b=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2]));
k++;
if(i==n-1&&j==n-1)break;
if(j==n-1)
{
i++;j=0;
}
else
j++;
}
for(i=0;i<n*n;i++)
{
for(k=0;k<n*n-i;k++)
{
if(juli[k].b<juli[k+1].b)
{
cache=juli[k+1];juli[k+1]=juli[k];juli[k]=cache;
}
}
}
int a1,a2;
for(i=0;i<n*n;i++)
{
if(juli[i].x>=juli[i].y)
continue;
else
{
a1=juli[i].x;a2=juli[i].y;
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[a1][0],a[a1][1],a[a1][2],a[a2][0],a[a2][1],a[a2][2],juli[i].b);
}
}
return 0;
}
| 64 |
31,907 | struct zz
{
float key;
int num1,num2;
}a[1005]={0,0,0},va;
int main()
{
int n;
cin>>n;
float x[n+5],y[n+5],z[n+5];
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].key=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].num1=i;
a[k].num2=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].key<a[j+1].key || (a[j].key == a[j+1].key && a[j].num1 > a[j+1].num1) || (a[j].key == a[j+1].key && a[j].num1 == a[j+1].num1 && a[j].num2 > a[j+1].num2))
{
va=a[j];
a[j]=a[j+1];
a[j+1]=va;
}
}
}
for(int i=0;i<(n-1)*n/2;i++)
printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",x[a[i].num1],y[a[i].num1],z[a[i].num1],x[a[i].num2],y[a[i].num2],z[a[i].num2],a[i].key);
return 0;
}
| 64 |
31,908 | 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 |
31,909 | int main(){
int n;
scanf("%d",&n);
int x[100]={0};
int y[100]={0};
int z[100]={0};
double d[4500]={0};
int i,j,t,p=0;
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
int k=0;
for(i=0;i<n-1;i++){
for(j=i+1;j<n;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]));
k++;
}
}
for(i=0;i<k-1;i++){
for(j=i+1;j<k;j++){
if(d[i]<d[j]){
double tmp;
tmp=d[i];
d[i]=d[j];
d[j]=tmp;
}
}
}
double a[4500]={0};
for(i=0;d[i]!=0;i++){
if(d[i]==d[i+1]){continue;}
else if(d[i]!=d[i+1]){a[p]=d[i];p++;}
}
for(i=0;i<p;i++){
if(a[i]==0){break;}
for(j=0;j<n;j++){
for(t=j+1;t<n;t++){
if(sqrt((x[t]-x[j])*(x[t]-x[j])+(y[t]-y[j])*(y[t]-y[j])+(z[t]-z[j])*(z[t]-z[j]))==a[i]){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[j],y[j],z[j],x[t],y[t],z[t],a[i]);
}
}
}
}
return 0;
}
| 64 |
31,910 |
int sq(int a,int b)
{ int r;
r=(a-b)*(a-b);
return(r);
}
float dis(int a[3],int b[3])
{ int i;
float s=0;
for(i=0;i<3;i++)
s+=sq(a[i],b[i]);
s=sqrt(s);
return(s);
}
void main()
{ int n,i,a[10][3],t=0,k,j,p;
float s[50][3],r;
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++)
{ s[t][0]=i;
s[t][1]=j;
s[t][2]=dis(a[i],a[j]);
t++;
}
for(j=1;j<=t-1;j++)
for(i=0;i<t-j;i++)
if(s[i][2]<s[i+1][2])
for(p=0;p<3;p++)
{ r=s[i][p];s[i][p]=s[i+1][p];s[i+1][p]=r; }
for(i=0;i<t;i++)
{ j=s[i][0];
k=s[i][1];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[j][0],a[j][1],a[j][2],a[k][0],a[k][1],a[k][2],s[i][2]);
}
} | 64 |
31,911 | int main(){
int n,m,i,j,r;
int a[10],b[10],c[10],f[100],g[100],h[100],x[100],y[100],z[100];
double d[100];
scanf("%d",&n);
m=0;
for(i=0;i<n;i++){
scanf("%d%d%d",&a[i],&b[i],&c[i]);}
for(i=n-2;i>=0;i--){
for(j=n-1;j>i;j--){
d[m]=(a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]);
d[m]=sqrt(d[m]);
f[m]=a[i];
g[m]=b[i];
h[m]=c[i];
x[m]=a[j];
y[m]=b[j];
z[m]=c[j];
m=m+1;}}
for(j=m-1;j>0;j--){
for(r=0;r<j;r++){
if(d[r]>d[r+1]){
double tmp;
int t1,t2,t3,t4,t5,t6;
tmp=d[r+1];
t1=f[r+1];
t2=g[r+1];
t3=h[r+1];
t4=x[r+1];
t5=y[r+1];
t6=z[r+1];
d[r+1]=d[r];
f[r+1]=f[r];
g[r+1]=g[r];
h[r+1]=h[r];
x[r+1]=x[r];
y[r+1]=y[r];
z[r+1]=z[r];
d[r]=tmp;
f[r]=t1;
g[r]=t2;
h[r]=t3;
x[r]=t4;
y[r]=t5;
z[r]=t6;
}
}
}
for(i=m-1;i>=0;i--){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",f[i],g[i],h[i],x[i],y[i],z[i],d[i]);
}
return 0;
}
| 64 |
31,912 | int main(){
int n,c,a,b,i,o,p;
double e;
scanf("%d",&n);
double jl[n][n];
int x[n],y[n],z[n];
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
for(a=0;a<n;a++){
b=a+1;
while(b<n){
c=(x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])+(z[a]-z[b])*(z[a]-z[b]);
jl[a][b]=sqrt(c);
b++;
}
}
e=0;
for(i=0;i!=-1;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++;
}
}
if(e==0){
break;
}
else{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[o],y[o],z[o],x[p],y[p],z[p],e);
jl[o][p]=0;
e=0;
}
}
return 0;
}
| 64 |
31,913 | int main()
{
int n,m=0,p,q,d;
double c,e;
scanf("%d",&n);
int sz[30];
int a[45],b[45];
for(int i=0;i<3*n;i++){
scanf("%d",&sz[i]);
}
double jl[45];
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
c=pow(1.0*(sz[3*j]-sz[3*i]),2.0)+pow(1.0*(sz[3*j+1]-sz[3*i+1]),2.0)+pow(1.0*(sz[3*j+2]-sz[3*i+2]),2.0);
jl[m]=sqrt(c);
a[m]=i;
b[m]=j;
m++;
}
}
for(p=1;p<n*(n-1)/2;p++){
for(q=0;q<n*(n-1)/2-p;q++){
if(jl[q]<jl[q+1]){
e=jl[q];
jl[q]=jl[q+1];
jl[q+1]=e;
d=a[q];
a[q]=a[q+1];
a[q+1]=d;
d=b[q];
b[q]=b[q+1];
b[q+1]=d;
}
}
}
for(p=0;p<n*(n-1)/2;p++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[3*a[p]],sz[3*a[p]+1],sz[3*a[p]+2],sz[3*b[p]],sz[3*b[p]+1],sz[3*b[p]+2],jl[p]);
}
return 0;
} | 64 |
31,914 | int main(){
int x[100],y[100],z[100],n,i,j,k=0,xx[100],yy[100],zz[100],xxx[100],yyy[100],zzz[100];
double juli[1000];
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++){
k++;
juli[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]));
xx[k]=x[i];
yy[k]=y[i];
zz[k]=z[i];
xxx[k]=x[j];
yyy[k]=y[j];
zzz[k]=z[j];
}
}
int a;
double b;
for(i=1;i<=k;i++){
for(j=1;j<=k-i;j++)
if (juli[j+1]>juli[j]){
b=juli[j];
juli[j]=juli[j+1];
juli[j+1]=b;
a=xx[j];
xx[j]=xx[j+1];
xx[j+1]=a;
a=yy[j];
yy[j]=yy[j+1];
yy[j+1]=a;
a=zz[j];
zz[j]=zz[j+1];
zz[j+1]=a;
a=xxx[j];
xxx[j]=xxx[j+1];
xxx[j+1]=a;
a=yyy[j];
yyy[j]=yyy[j+1];
yyy[j+1]=a;
a=zzz[j];
zzz[j]=zzz[j+1];
zzz[j+1]=a;
}
}
for(i=1;i<=k;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",xx[i],yy[i],zz[i],xxx[i],yyy[i],zzz[i],juli[i]);
}
return 0;
}
| 64 |
31,915 | int main()
{
int n,l=0,a[101],i,j,b[101],c[101],f[50],g[50],x;
double e[50],y;
for(i=0;i<50;i++){e[i]=0;}
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+1;i<n;i++)
{
e[l]=sqrt((a[j]-a[i])*(a[j]-a[i])+(b[j]-b[i])*(b[j]-b[i])+(c[j]-c[i])*(c[j]-c[i]));
f[l]=j;
g[l]=i;
l++;
}
}
for(l=0;l<(n*(n-1))/2;l++)
{
for(i=0;i<(n*(n-1)/2-1);i++)
{
if(e[i]<e[i+1])
{
y=e[i];
e[i]=e[i+1];
e[i+1]=y;
x=f[i];
f[i]=f[i+1];
f[i+1]=x;
x=g[i];
g[i]=g[i+1];
g[i+1]=x;
}
}
}
for(l=0;l<n*(n-1)/2;l++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[f[l]],b[f[l]],c[f[l]],a[g[l]],b[g[l]],c[g[l]],e[l]);
}
return 0;
}
| 64 |
31,916 | //********************************
//*??????? **
//*?????? 1300012713 **
//*???2013.12.14 **
//********************************
int main()
{
int n, b = 0,a[15][3];
struct distance
{
double ds;
int a1;
int a2;
}d[50];
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i][0] >> a[i][1] >> a[i][2];
for(int j = 1; j <= n; j++)
{
for(int k = j + 1; k <= n; k++)
{
b++;
d[b].ds = sqrt((a[j][0]-a[k][0])*(a[j][0]-a[k][0])
+(a[j][1]-a[k][1])*(a[j][1]-a[k][1])
+(a[j][2]-a[k][2])*(a[j][2]-a[k][2]));
d[b].a1 = j;
d[b].a2 = k;
}
}
for(int p = 1; p <= b; p++)
{
for(int q = 1; q <= b-p+1; q++)
{
if(d[q].ds < d[q+1].ds)
{
double b0 = d[q].ds; int b1 = d[q].a1; int b2 = d[q].a2;
d[q].ds = d[q+1].ds; d[q].a1 = d[q+1].a1; d[q].a2 = d[q+1].a2;
d[q+1].ds = b0; d[q+1].a1 = b1; d[q+1].a2 = b2;
}
}
}
for(int l = 1; l <= b; l++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[d[l].a1][0],a[d[l].a1][1],a[d[l].a1][2],a[d[l].a2][0],a[d[l].a2][1],a[d[l].a2][2],d[l].ds);
return 0;
} | 64 |
31,917 |
int main()
{
struct point
{
int x;
int y;
int z;
}p[10];
struct distance
{
int x1,x2;
int y1,y2;
int z1,z2;
double d;
}d[46],t;
int n,i,j,k=0,m;
cin>>n;
for(i=0;i<n;i++)
{
cin>>p[i].x>>p[i].y>>p[i].z;
}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
d[k].x1=p[i].x;
d[k].x2=p[j].x;
d[k].y1=p[i].y;
d[k].y2=p[j].y;
d[k].z1=p[i].z;
d[k].z2=p[j].z;
d[k].d=sqrt(((double)d[k].x1-(double)d[k].x2)*((double)d[k].x1-(double)d[k].x2)+((double)d[k].y1-(double)d[k].y2)*((double)d[k].y1-(double)d[k].y2)+((double)d[k].z1-(double)d[k].z2)*((double)d[k].z1-(double)d[k].z2));
k++;
}
m=k;
struct distance *pointer1,*pointer2;
pointer1=d;
pointer2=&t;
for(i=0;i<m-1;i++)
for(j=m-1;j>i;j--)
{
if((pointer1+j)->d>(pointer1+j-1)->d)
{
*pointer2=*(pointer1+j);
*(pointer1+j)=*(pointer1+j-1);
*(pointer1+j-1)=*pointer2;
}
}
for(k=0;k<m;k++)
{
cout<<"("<<d[k].x1<<","<<d[k].y1<<","<<d[k].z1<<")"<<"-"<<"("<<d[k].x2<<","<<d[k].y2<<","<<d[k].z2<<")"<<"="
<<fixed<<setprecision(2)<<d[k].d<<endl;
}
return 0;
} | 64 |
31,918 | //************************
//*??????? **
//*?????? **
//*???1200012957 **
//*???2012-12-13 **
//************************
struct point // ???????????????
{
int x;
int y;
int z;
} p[10]; // ?????
struct distance // ???????????????????????????????
{
int f;
int b;
double s;
} a[45];
int main ()
{
int n, i, j, k = 0;
cin >> n; // ?????
for (i = 0; i < n; i++ )
{
// ???????
cin >> p[i].x >> p[i].y >> p[i].z ;
}
int m = n * (n - 1) / 2; // ?????????????
for (i = 0; i < n - 1; i++ )
{
for ( j = i + 1; j < n; j++ )
{
// ?????????
a[k].s = sqrt((p[i].x - p[j].x) * (p[i].x - p[j].x) +
(p[i].y - p[j].y) * (p[i].y - p[j].y) +
(p[i].z - p[j].z) * (p[i].z - p[j].z));
a[k].f = i; // ?????????????
a[k].b = j;
k++ ;
}
}
for (i = 0; i < m; i++ )
{
k = i;
for (j = i + 1; j < m; j++ )
{
// ??????????
if (a[k].s < a[j].s)
{
k = j;
}
else
{
// ?????????????????
if (a[k].s == a[j].s)
{
// ??????????????????????
if ((a[k].f > a[j].f) ||
((a[k].f == a[j].f) && (a[k].b > a[j].b)))
{
k = j;
}
}
}
}
// ??????
cout << "(" << p[a[k].f].x << "," << p[a[k].f].y << "," << p[a[k].f].z << ")-";
cout << "(" << p[a[k].b].x << "," << p[a[k].b].y << "," << p[a[k].b].z << ")=";
cout << setprecision(2) << fixed << a[k].s << endl;
a[k] = a[i];
}
return 0;
} | 64 |
31,919 | int main()
{
int n=0,k=0,j=0,count=0;//?????????
float x[10],y[10],z[10],d[45];//???????
int name[45][3];//??????????
cin>>n;
for(k=0;k<n;k++)//????
{
cin>>x[k]>>y[k]>>z[k];
}
for(k=0;k<n-1;k++)//????
{
for(j=k+1;j<n;j++)
{
d[count]=sqrt((x[k]-x[j])*(x[k]-x[j])+(y[k]-y[j])*(y[k]-y[j])+(z[k]-z[j])*(z[k]-z[j]));//??
name[count][1]=k;//??
name[count][2]=j;//??
count++;
}
}
for(k=0;k<count-1;k++)//?????
for(j=0;j<count-1-k;j++)
if(d[j]<d[j+1])
{
float a;
a=d[j];d[j]=d[j+1];d[j+1]=a;
a=name[j][1];name[j][1]=name[j+1][1];name[j+1][1]=a;
a=name[j][2];name[j][2]=name[j+1][2];name[j+1][2]=a;
}
for(k=0;k<count;k++)//??
{
cout<<"("<<x[name[k][1]]<<","<<y[name[k][1]]<<","<<z[name[k][1]]<<")-("<<x[name[k][2]]<<","<<y[name[k][2]]<<","<<z[name[k][2]]<<")=";
printf("%.2f\n",d[k]);
}
return 0;
} | 64 |
31,920 | int main(){
int a[10][3];
int n;
int i,j,k;
double ans[100];
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*n+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 max = 1;
for(i = 0;i<n;++i){
for(j = i+1;j<n;++j){
if(ans[i*n+j] > ans[max])max = i*n+j;
}
}
//(1,1,0)-(1,1,1)=1.00
cout<<"("<<a[max/n][0]<<","<<a[max/n][1]<<","<<a[max/n][2]<<")-("
<<a[max%n][0]<<","<<a[max%n][1]<<","<<a[max%n][2]<<")="
<<fixed<<setprecision(2)<<ans[max]<<endl;
ans[max] = -9999999;
}
cin>>i;
return 0;
}
| 64 |
31,921 | 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 |
31,922 | int main()
{
int i,n,k,p=0,f;
int c[100],d[100];
int a[100][50];
double b[200],q,e;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i][0]);
scanf("%d",&a[i][1]);
scanf("%d",&a[i][2]);
}
for(i=0;i<n;i++)
{
for(k=i+1;k<n;k++)
{
q=(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]);
b[p]=sqrt(q);
c[p]=i;
d[p]=k;
p++;
}
}
for(i=1;i<=p;i++)
{
for(k=0;k<p-i;k++)
{
if(b[k+1]>b[k])
{
e=b[k+1];
b[k+1]=b[k];
b[k]=e;
f=c[k+1];
c[k+1]=c[k];
c[k]=f;
f=d[k+1];
d[k+1]=d[k];
d[k]=f;
}
}
}
for(i=0;i<p;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[c[i]][0],a[c[i]][1],a[c[i]][2],a[d[i]][0],a[d[i]][1],a[d[i]][2],b[i]);
}
return 0;
} | 64 |
31,923 | int main(){
int i,a[1000][3],n,e,j,k=0,h;
double m[3000][3],r,p,q;
scanf("%d",&n);
h=n*(n-1)/2;
for(i=0;i<n;i++)
{
scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
m[k][0]=i;
m[k][1]=j;
m[k][2]=sqrt((double) ((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])));
k++;
}
}
for(i=1;i<h;i++)
{
for(k=0;k<h-i;k++)
{
if(m[k][2]<m[k+1][2])
{
r=m[k][0];
m[k][0]=m[k+1][0];
m[k+1][0]=r;
p=m[k][1];
m[k][1]=m[k+1][1];
m[k+1][1]=p;
q=m[k][2];
m[k][2]=m[k+1][2];
m[k+1][2]=q;
}
}
}
for(i=0;i<h;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[(int)m[i][0]][0],a[(int)m[i][0]][1],a[(int)m[i][0]][2],a[(int)m[i][1]][0],a[(int)m[i][1]][1],a[(int)m[i][1]][2],m[i][2]);
return 0;
} | 64 |
31,924 | int main()
{
int n,i,j,k,r,c;
float a[10][3],b[11][11],sum,max;
cin>>n;
for(i=0;i<n;i++)
{
for(j=0;j<3;j++)
cin>>a[i][j];
}
for(i=0;i<n-1;i++)
{
for(k=i+1;k<n;k++)
{
sum=0;
for(j=0;j<3;j++)
{
sum=sum+(a[i][j]-a[k][j])*(a[i][j]-a[k][j]);
}
b[i][k]=sqrt(sum);
}
}
for(j=0;j<(n-1)*n/2;j++)
{
max=0;
for(i=0;i<n-1;i++)
{
for(k=i+1;k<n;k++)
{
if(b[i][k]>max)
{
max=b[i][k];
r=i;
c=k;
}
}
}
b[r][c]=0;
cout<<'('<<a[r][0]<<','<<a[r][1]<<','<<a[r][2]<<')'<<'-'<<'('<<a[c][0]<<','<<a[c][1]<<','<<a[c][2]<<')'<<'=';
printf("%.2f\n",max);
}
return 0;
} | 64 |
31,925 | 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 |
31,926 | 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 |
31,927 | struct equal{
int i1,j1,k1;
int i2,j2,k2;
double distance;
};
void bubblesort(struct equal d[],int n);
struct node{
int i,j,k;
};
int main(){
int n,i;
scanf("%d",&n);
struct node aa[n];
for( i=0;i<n;i++)
{scanf("%d%d%d",&(aa[i].i),&(aa[i].j),&(aa[i].k));
}
struct equal equal1[1000];
int a,b,c,g,p=0;
for(a=0;a<n;a++){
for(b=a+1;b<n;b++){
equal1[p].i1=aa[a].i;equal1[p].j1=aa[a].j;equal1[p].k1=aa[a].k;
equal1[p].i2=aa[b].i;equal1[p].j2=aa[b].j;equal1[p].k2=aa[b].k;
equal1[p].distance=sqrt(pow((double)(equal1[p].i1-equal1[p].i2),2)+pow((double)(equal1[p].j1-equal1[p].j2),2)+pow((double)(equal1[p].k1-equal1[p].k2),2));
p++;
}
}
bubblesort(equal1,p);
for(g=0;g<p;g++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",equal1[g].i1,equal1[g].j1,equal1[g].k1,equal1[g].i2,equal1[g].j2,equal1[g].k2,equal1[g].distance);
}
return 0;
}
void bubblesort(struct equal d[],int n){
int i,j,m;double t;
for(i=0;i<n;i++){
for(j=n-1;j>i;j--){
if(d[j].distance>d[j-1].distance){
t=d[j].distance;d[j].distance=d[j-1].distance;d[j-1].distance=t;
m=d[j].i1;d[j].i1=d[j-1].i1;d[j-1].i1=m;
m=d[j].i2;d[j].i2=d[j-1].i2;d[j-1].i2=m;
m=d[j].j1;d[j].j1=d[j-1].j1;d[j-1].j1=m;
m=d[j].k1;d[j].k1=d[j-1].k1;d[j-1].k1=m;
m=d[j].j2;d[j].j2=d[j-1].j2;d[j-1].j2=m;
m=d[j].k2;d[j].k2=d[j-1].k2;d[j-1].k2=m;
}
}
}
}
| 64 |
31,928 |
int main(){
int n,nn;
int a[101],b[101],c[101],x[46][3],y[46][3],xx[46],yy[46],px,py,pz;
double jl[46],m;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d %d %d",&a[i],&b[i],&c[i]);
}
int d=0;
for(int w=0;w<n;w++){
for(int j=w+1;j<n;j++){
jl[d]=sqrt(1.0*(a[w]-a[j])*(a[w]-a[j])+(b[w]-b[j])*(b[w]-b[j])+(c[w]-c[j])*(c[w]-c[j]));
x[d][0]=a[w];
x[d][1]=b[w];
x[d][2]=c[w];
y[d][0]=a[j];
y[d][1]=b[j];
y[d][2]=c[j];
xx[d]=w;
yy[d]=j;
d++;
}
}
for(int k=1;k<=n*(n-1)/2;k++){
for(int j=0;j<n*(n-1)/2-k;j++){
if(jl[j]>jl[j+1]||(xx[j]<xx[j+1]&&jl[j]==jl[j+1])||(yy[j]<yy[j+1]&&xx[j]==xx[j+1]&&jl[j]==jl[j+1])){
m=jl[j+1];
jl[j+1]=jl[j];
jl[j]=m;
nn=xx[j+1];
xx[j+1]=xx[j];
xx[j]=nn;
nn=yy[j+1];
yy[j+1]=yy[j];
yy[j]=nn;
px=x[j+1][0];
py=x[j+1][1];
pz=x[j+1][2];
x[j+1][0]=x[j][0];
x[j+1][1]=x[j][1];
x[j+1][2]=x[j][2];
x[j][0]=px;
x[j][1]=py;
x[j][2]=pz;
px=y[j+1][0];
py=y[j+1][1];
pz=y[j+1][2];
y[j+1][0]=y[j][0];
y[j+1][1]=y[j][1];
y[j+1][2]=y[j][2];
y[j][0]=px;
y[j][1]=py;
y[j][2]=pz;
}
}
}
for(int j=n*(n-1)/2-1;j>=0;j--){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[j][0],x[j][1],x[j][2],y[j][0],y[j][1],y[j][2],jl[j]);
}
}
| 64 |
31,929 | 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 |
31,930 | int main(){
int n,i,p,j,e,k,u;
double s[50];
int x[10],y[10],z[10];
struct result{
int x1,y1,z1,x2,y2,z2;
double s;
}a[50],t;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
p=(n*(n-1))/2;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
e=(n-1.0*(i+1)/2)*i+j-i-1;
u=(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[e]=sqrt(1.0*u);
}
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
e=(n-1.0*(i+1)/2)*i+j-i-1;
a[e].x1=x[i];
a[e].y1=y[i];
a[e].z1=z[i];
a[e].x2=x[j];
a[e].y2=y[j];
a[e].z2=z[j];
a[e].s=s[e];
}
}
for(k=1;k<=p;k++){
for(i=0;i<p-k;i++){
if(a[i].s<a[i+1].s){
t=a[i+1];
a[i+1]=a[i];
a[i]=t;
}
}
}
for(i=0;i<p;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[i].x1,a[i].y1,a[i].z1,a[i].x2,a[i].y2,a[i].z2,a[i].s);
}
return 0;
} | 64 |
31,931 | int main()
{
int n,a[10][3],i,j,k;
double b[10][10];
cin>>n;
for(i=0;i<=n-1;i++)
for(j=0;j<=2;j++)
cin>>a[i][j];
for(i=0;i<=n-1;i++)
for(j=i+1;j<=n-1;j++)
b[i][j]=sqrt(pow((double)(a[i][0]-a[j][0]),2)+pow((double)(a[i][1]-a[j][1]),2)+pow((double)(a[i][2]-a[j][2]),2));
for(k=1;k<=n*(n-1)/2;k++)
{
double r=-1;
int first,next;
for(i=0;i<=n-1;i++)
for(j=i+1;j<=n-1;j++){
if(b[i][j]>r){
r=b[i][j];
first = i;
next = j;
}
}
cout<<"("<<a[first][0]<<","<<a[first][1]<<","<<a[first][2]<<")-("
<<a[next][0]<<","<<a[next][1]<<","<<a[next][2]<<")="
<<fixed<<setprecision(2)<<r<<endl;
b[first][next] = -9999999;
}
cin>>n;
return 0;
}
| 64 |
31,932 | int main()
{
int n, i, j, k, c[10][3], temp = 0,count = 0;
cin >> n;
struct
{
int a[3];
int b[3];
int flag1;
int flag2;
double distance;
}dian[46] = {0};
for (i = 0; i < n; i++)
for (j = 0; j < 3; j++)
cin >> c[i][j];
for (i = 0; i < n; i++)
for (j = i + 1; j < n; j++)
{
temp = 0;
for (k = 0; k < 3; k++)
{
dian[count].a[k] = c[i][k];
dian[count].b[k] = c[j][k];
dian[count].flag1 = i;
dian[count].flag2 = j;
temp = temp + (c[i][k] - c[j][k]) * (c[i][k] - c[j][k]);
}
dian[count].distance = sqrt(temp);
count++;
}
for (i = count - 1; i >= 0; i--)
for (j = count - 1; j >= 0; j--)
if ((dian[i].distance > dian[j].distance && i > j) || ((dian[i].distance == dian[j].distance) && ((dian[i].flag1 < dian[j].flag1 && i > j) || (dian[i].flag1 == dian[j].flag1 && dian[i].flag2 < dian[j].flag2 && i > j))))
{
dian[45] = dian[i];
dian[i] = dian[j];
dian[j] = dian[45];
}
for (i = 0; i < count; i++)
cout << "(" << dian[i].a[0] << "," << dian[i].a[1] << "," << dian[i].a[2] << ")" << "-" << "(" << dian[i].b[0] << "," << dian[i].b[1] << "," << dian[i].b[2] << ")" << "=" << fixed << setprecision(2) << dian[i].distance << endl;
return 0;
} | 64 |
31,933 | //????????
struct point{
int x;
int y;
int z;
}input[10]={0};
struct point u;
struct point v;
struct total{
struct point u;
struct point v;
double result;
}output[45]={0};
//???????????
double distance(struct point a,struct point b)
{
return(sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z)));
}
void sort(struct total c[],int d)
{
int m,n;
struct total temp;
for(m=1;m<d;m++)
for(n=0;n<d-m;n++)
if(c[n].result<c[n+1].result){
temp=c[n];
c[n]=c[n+1];
c[n+1]=temp;
}
}
//???
void main()
{
int n,i,j,p;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&input[i].x,&input[i].y,&input[i].z);
p=-1;
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
p++;
output[p].u=input[i];
output[p].v=input[j];
output[p].result=distance(output[p].u,output[p].v);
}
}
sort(output,p+1);
for(i=0;i<=p;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",output[i].u.x,output[i].u.y,output[i].u.z,output[i].v.x,output[i].v.y,output[i].v.z,output[i].result);
}
| 64 |
31,934 | int main()
struct d{
int x;
int y;
int z;};
{
struct d s[10];
int n,i,j,k=0,d;
int x,y,z,b[45],c[45];
double a[45],temp;
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++)
{ x=s[i].x-s[j].x;
y=s[i].y-s[j].y;
z=s[i].z-s[j].z;
a[k]=(x*x+y*y+z*z);
a[k]=sqrt(a[k]);
b[k]=i;
c[k]=j;
k++;
}
for(i=0;i<k;i++)
for(j=i+1;j<k;j++)
{if((a[i]<a[j])||((a[i]==a[j])&&(b[i]>b[j]))||((a[i]==a[j])&&(c[i]>c[j])))
{temp=a[j];
a[j]=a[i];
a[i]=temp;
temp=b[j];
b[j]=b[i];
b[i]=temp;
temp=c[j];
c[j]=c[i];
c[i]=temp;
}
}
for(i=0;i<k;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",s[b[i]].x,s[b[i]].y,s[b[i]].z,s[c[i]].x,s[c[i]].y,s[c[i]].z,a[i]);
scanf("%d",&d);
return 0;
} | 64 |
31,935 | //**************************
//*???????? *
//*??????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 |
31,936 | int main(){
int x[10],y[10],z[10];
double l[10][10];
double d[100];
double m;
int i,j,k,n;
int s=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=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]));
d[s]=l[i][j];
s+=1;
}
}
for(i=0;i<n*n;i++){
for(j=0;j<n*(n-1)/2-1;j++){
if(d[j]<d[j+1]){
m=d[j];
d[j]=d[j+1];
d[j+1]=m;
}
}
}
for(k=0;k<n*(n-1)/2;k++){
while(d[k]==d[k-1]){
k+=1;
}
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(l[i][j]==d[k]){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],d[k]);
}
}
}
}
return 0;
} | 64 |
31,937 | int main()
{
int i,n,j=1,x[11],y[11],z[11],a,b,k;
double d[50],t;
cin>>n;
for(i=1;i<=n;i++)
cin>>x[i]>>y[i]>>z[i];
for(i=1;i<n;i++)
for(k=i+1;k<=n;k++)
{
d[j]=sqrt(pow(x[i]-x[k],2.0)+pow(y[i]-y[k],2.0)+pow(z[i]-z[k],2.0));
j++;
}
for(j=1;j<=(n*(n-1)/2-1);j++)
for(i=1;i<=(n*(n-1)/2-j);i++)
if (d[i]<d[i+1])
{t=d[i];d[i]=d[i+1];d[i+1]=t;}
for(i=1;i<=(n*(n-1)/2);i++)
{
if(d[i]==d[i+1])
continue;
for(a=1;a<n;a++)
for(b=a+1;b<=n;b++)
if(sqrt(pow(x[a]-x[b],2.0)+pow(y[a]-y[b],2.0)+pow(z[a]-z[b],2.0))==d[i])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[a],y[a],z[a],x[b],y[b],z[b],d[i]);
}
return 0;
} | 64 |
31,938 | int main()
{
int n,i,j,d=1,t,x[12],y[12],z[12];
float g;
struct juli
{
int a;
int b;
float jl;
}l[100];
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
for(i=1;i<=n-1;i++)
{
for(j=i+1;j<=n;j++)
{
l[d].jl=sqrt(((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]))*1.0);
l[d].a=i;
l[d].b=j;
d++;
}
}
d--;
for(i=1;i<=d-1;i++)
{
for(j=1;j<=d-i;j++)
{
if (l[j].jl<l[j+1].jl)
{
g=l[j].jl;
l[j].jl=l[j+1].jl;
l[j+1].jl=g;
t=l[j].a;
l[j].a=l[j+1].a;
l[j+1].a=t;
t=l[j].b;
l[j].b=l[j+1].b;
l[j+1].b=t;
}
}
}
for(i=1;i<=d;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[l[i].a],y[l[i].a],z[l[i].a],x[l[i].b],y[l[i].b],z[l[i].b],l[i].jl);
}
return 0;
} | 64 |
31,939 | int main()
{
int n,i,j,a[80],b[80],k=0,m,code1,code2;
double x[13],y[13],z[13],S[80],t;
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++)//????Cn2
{
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]=i;b[k]=j;
k++;//
}
for(i=0;i<k;i++)
for(j=k-1;j>i;j--)//?????
if(S[j]>S[j-1])
{
t=S[j];
S[j]=S[j-1];
S[j-1]=t;//????
m=a[j];
a[j]=a[j-1];
a[j-1]=m;//???????
m=b[j];
b[j]=b[j-1];
b[j-1]=m;//???????
}
for(i=0;i<k;i++)
{
code1=a[i];code2=b[i];
cout<<"("<<(int)x[code1]<<","<<(int)y[code1]<<","<<(int)z[code1]<<")-("<<(int)x[code2]<<","<<(int)y[code2]<<","<<(int)z[code2]<<")=";
cout<<fixed<<setprecision(2);
cout<<S[i]<<endl;
}
return 0;
} | 64 |
31,940 |
struct point{
int x;
int y;
int z;
};
struct distanceBetweenPoints{
int pointIndex1;
int pointIndex2;
double distace;
};
double distance(struct point p1, struct point p2){
double d =0.0;
d = sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y - p2.y)*(p1.y - p2.y) + (p1.z - p2.z)*(p1.z - p2.z));
return d;
}
int main(int argc, const char * argv[])
{
int n;
scanf("%d", &n);
struct point points[n];
for (int j=0; j<n; j++) {
scanf("%d %d %d", &points[j].x, &points[j].y, &points[j].z);
}
struct distanceBetweenPoints distances[n*(n-1)/2];
int index = 0;
for (int index1=0; index1<n; index1++) {
for (int index2=index1+1; index2<n; index2++) {
double d = distance(points[index1], points[index2]);
distances[index].distace = d;
distances[index].pointIndex1 = index1;
distances[index].pointIndex2 = index2;
index ++;
}
}
for (int i=0; i<index; i++) {
for (int j=1; j<index-i; j++) {
if (distances[j-1].distace < distances[j].distace) {
struct distanceBetweenPoints temp;
temp = distances[j-1];
distances[j-1] = distances[j];
distances[j] = temp;
}
}
}
for (int i = 0; i < index; i++) {
printf("(%d,%d,%d)",points[distances[i].pointIndex1].x, points[distances[i].pointIndex1].y, points[distances[i].pointIndex1].z);
printf("-");
printf("(%d,%d,%d)",points[distances[i].pointIndex2].x, points[distances[i].pointIndex2].y, points[distances[i].pointIndex2].z);
printf("=");
printf("%.2lf\n", distances[i].distace);
}
return 0;
}
| 64 |
31,941 |
double juli(int i1, int i2, int i3, int i4, int i5, int i6);
int main()
{
int n, i, j, k, q = 0, m;
double temp;
int a[100], b[100], c[100], f[100], g[100];
double e[100];
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++)
{
e[q] = juli(a[i], b[i], c[i], a[j], b[j], c[j]);
f[q] = i;
g[q] = j;
q++;
}
}
m = n*(n-1)/2;
for(k = 1; k <= m; k++)
{
for(i = 0; i < m-k; i++)
{
if(e[i] < e[i+1])
{
temp = e[i+1];
e[i+1] = e[i];
e[i] = temp;
temp = f[i+1];
f[i+1] = f[i];
f[i] = temp;
temp = g[i+1];
g[i+1] = g[i];
g[i] = temp;
}
}
}
for(i = 0; i < m; i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[f[i]], b[f[i]], c[f[i]], a[g[i]], b[g[i]], c[g[i]], e[i]);
return 0;
}
double juli(int i1, int i2, int i3, int i4, int i5, int i6)
{
double s;
s = sqrt((i4-i1)*(i4-i1) + (i5-i2)*(i5-i2) + (i6-i3)*(i6-i3));
return s;
}
| 64 |
31,942 | int main()
{
int n,i,j,r,k=0,a[10][3],c[45],d[45];
double b[45];
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;i++)
{
for(j=i+1;j<n;j++)
{
b[k]=sqrt((a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2])+(a[i][0]-a[j][0])*(a[i][0]-a[j][0]));
c[k]=i;
d[k]=j;
k++;
}
}
for(i=1;i<n*(n-1)/2;i++)
{
double tmp=b[i];
for(j=i-1;j>=0;j--)
{
if(tmp>b[j])
{
b[j+1]=b[j];
b[j]=tmp;
r=c[j];
c[j]=c[j+1];
c[j+1]=r;
r=d[j];
d[j]=d[j+1];
d[j+1]=r;
}
else
{
b[j+1]=tmp;
break;
}
}
}
for(k=0;k<n*(n-1)/2;k++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[c[k]][0],a[c[k]][1],a[c[k]][2],a[d[k]][0],a[d[k]][1],a[d[k]][2],b[k]);
}
return 0;
}
| 64 |
31,943 | struct dir{
int dot1[3];
int dot2[3];
float dis;
} dir[50];
struct dir temp;
int num[30];
int dot[50][3];
int n,i,j,p=0,a,b;
int main()
{
scanf("%d",&n);
for(i=1;i<=3*n;i++)
{
scanf("%d",&num[i]);
if(i%3!=0)
{
a=i/3;
b=i%3-1;
dot[a][b]=num[i];
}
else dot[i/3-1][2]=num[i];
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
dir[p].dot1[0]=dot[i][0];dir[p].dot1[1]=dot[i][1];dir[p].dot1[2]=dot[i][2];
dir[p].dot2[0]=dot[j][0];dir[p].dot2[1]=dot[j][1];dir[p].dot2[2]=dot[j][2];
dir[p].dis=sqrt((dot[i][0]-dot[j][0])*(dot[i][0]-dot[j][0])+(dot[i][1]-dot[j][1])*(dot[i][1]-dot[j][1])+(dot[i][2]-dot[j][2])*(dot[i][2]-dot[j][2]));
p++;
}
}
for(i=1;i<p;i++)
{
for(j=0;j<p-i;j++)
{
if(dir[j].dis<dir[j+1].dis)
{
temp=dir[j];
dir[j]=dir[j+1];
dir[j+1]=temp;
}
}
}
for(i=0;i<p;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dir[i].dot1[0],dir[i].dot1[1],dir[i].dot1[2],dir[i].dot2[0],dir[i].dot2[1],dir[i].dot2[2],dir[i].dis);
}
return 0;
}
| 64 |
31,944 |
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 |
31,945 | 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[100];
Input(p,n);
double a[100];
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,946 | void main()
{
int m,n,i,j,k,a,c,t,u;
int tt[100][3];
int pp[10000][6];
float xx[10000],b;
scanf("%d",&m);
for(i=0;i<m;i++)
{
for(u=0;u<3;u++)
{
scanf("%d",&tt[i][u]);
}
}
n=m*(m-1)/2;
t=n;
for(a=0,j=0;j<m-1;j++)
{
for(k=j+1;k<m;k++,a++)
{
xx[a]=sqrt((tt[j][0]-tt[k][0])*(tt[j][0]-tt[k][0])+(tt[j][1]-tt[k][1])*(tt[j][1]-tt[k][1])+(tt[j][2]-tt[k][2])*(tt[j][2]-tt[k][2]));
pp[a][0]=tt[j][0];
pp[a][1]=tt[j][1];
pp[a][2]=tt[j][2];
pp[a][3]=tt[k][0];
pp[a][4]=tt[k][1];
pp[a][5]=tt[k][2];
}
}
for(i=0;i<n-1;n--)
{
for(j=i;j<n-1;j++)
{
if(xx[j]<xx[j+1])
{
b=xx[j]; xx[j]=xx[j+1]; xx[j+1]=b;
c=pp[j][0]; pp[j][0]=pp[j+1][0]; pp[j+1][0]=c;
c=pp[j][1]; pp[j][1]=pp[j+1][1]; pp[j+1][1]=c;
c=pp[j][2]; pp[j][2]=pp[j+1][2]; pp[j+1][2]=c;
c=pp[j][3]; pp[j][3]=pp[j+1][3]; pp[j+1][3]=c;
c=pp[j][4]; pp[j][4]=pp[j+1][4]; pp[j+1][4]=c;
c=pp[j][5]; pp[j][5]=pp[j+1][5]; pp[j+1][5]=c;
}
}
}
for(k=0;k<t;k++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",pp[k][0],pp[k][1],pp[k][2],pp[k][3],pp[k][4],pp[k][5],xx[k]);
}
}
| 64 |
31,947 |
struct Point
{
int x1;
int x2;
int x3;
}point1,point2,p[11];
struct Dis
{
struct Point point1;
struct Point point2;
float d;
}dis[46],tmp;
int main()
{
int n,i,j,m,k;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d%d%d",&p[i].x1,&p[i].x2,&p[i].x3);
}
for(k=0,m=n-1;m>0;m--)
{
for(i=1;i<=m;i++)
{
dis[k+i].point1=p[n-m];
dis[k+i].point2=p[n-m+i];
dis[k+i].d=sqrt((dis[k+i].point1.x1-dis[k+i].point2.x1)*(dis[k+i].point1.x1-dis[k+i].point2.x1)+(dis[k+i].point1.x2-dis[k+i].point2.x2)*(dis[k+i].point1.x2-dis[k+i].point2.x2)+(dis[k+i].point1.x3-dis[k+i].point2.x3)*(dis[k+i].point1.x3-dis[k+i].point2.x3));
}
k=k+m;
}
for(i=1;i<(n*(n-1)/2);i++)
{
for(j=1;j<=(n*(n-1)/2-i);j++)
{
if(dis[j].d<dis[j+1].d)
{
tmp=dis[j];
dis[j]=dis[j+1];
dis[j+1]=tmp;
}
}
}
for(i=1;i<=n*(n-1)/2;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dis[i].point1.x1,dis[i].point1.x2,dis[i].point1.x3,dis[i].point2.x1,dis[i].point2.x2,dis[i].point2.x3,dis[i].d);
}
return 0;
}
| 64 |
31,948 |
int main() {
int n;
scanf("%d",&n);
struct coordinate{int x;int y;int z;int io;}pt[n];
int i;
for(i=0;i<n;i=i+1)
{
scanf("%d %d %d",&(pt[i].x),&(pt[i].y),&(pt[i].z));
pt[i].io=i;
}
int j;
int m;
m=n*(n-1)/2;//?????
struct distance{struct coordinate pt1;struct coordinate pt2;double l;}dist[m];
int t=0;
for(i=0;i<n;i=i+1)
{
for(j=i+1;j<n;j=j+1)
{
dist[t].pt1=pt[i];
dist[t].pt2=pt[j];
dist[t].l=sqrt(pow(1.0*(dist[t].pt1.x-dist[t].pt2.x),2.0)+pow(1.0*(dist[t].pt1.y-dist[t].pt2.y),2.0)+pow(1.0*(dist[t].pt1.z-dist[t].pt2.z),2.0));
t=t+1;
}
}
struct distance temp;
int s=0;
while(s==0)
{
s=1;
for(i=0;i<m-1;i++)
{
if(dist[i].l<dist[i+1].l)
{
temp=dist[i];
dist[i]=dist[i+1];
dist[i+1]=temp;
s=0;
}
}
}
for(i=0;i<m;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dist[i].pt1.x,dist[i].pt1.y,dist[i].pt1.z,dist[i].pt2.x,dist[i].pt2.y,dist[i].pt2.z,dist[i].l);
}
return(0);
}
| 64 |
31,949 |
float ju(int *p,int *q){
float s=0;
int i=0;
for(i=0;i<3;i++){
s=(*(p)-*(q)) * (*(p)-*(q))+s;
p++,q++;}
return s=sqrt(s);}
int main()
{
struct s{
int i;
int j;
float l;
}
s[100],t;
int n,a[11][3]={0},i,j,p=0,k;
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;i++){
for(j=i+1;j<n;j++){
s[p].i=i,s[p].j=j,s[p].l=ju(a[i],a[j]),p++;}
}
for(i=0;i<p;i++){
for(j=i+1;j<p;j++){
if(s[i].l<s[j].l)t=s[i],s[i]=s[j],s[j]=t;
else if(s[i].l==s[j].l){
if(s[i].i>s[j].i)t=s[i],s[i]=s[j],s[j]=t;
else if(s[i].i==s[j].i&&s[i].j>s[j].j)t=s[i],s[i]=s[j],s[j]=t;
}
}
}
for(i=0;i<p;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[s[i].i][0],a[s[i].i][1],a[s[i].i][2],a[s[i].j][0],a[s[i].j][1],a[s[i].j][2],s[i].l);}
} | 64 |
31,950 | struct POINT {
int x;
int y;
int z;
};
struct DIST {
int a;
int b;
double dis;
};
int main()
{
int n,i,j,k,t;
double td;
struct POINT point[20];
struct DIST dists[200];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].z);
}
k=0;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
dists[k].a=i;
dists[k].b=j;
dists[k].dis=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));
k++;
}
}
for(i=0;i<k;i++)
{
for(j=k-1;j>i;j--)
{
if(dists[j].dis>dists[j-1].dis)
{
t=dists[j].a;
dists[j].a=dists[j-1].a;
dists[j-1].a=t;
t=dists[j].b;
dists[j].b=dists[j-1].b;
dists[j-1].b=t;
td=dists[j].dis;
dists[j].dis=dists[j-1].dis;
dists[j-1].dis=td;
}
}
}
for(i=0;i<k;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",
point[dists[i].a].x,point[dists[i].a].y,point[dists[i].a].z,
point[dists[i].b].x,point[dists[i].b].y,point[dists[i].b].z,
dists[i].dis);
}
return 0;
} | 64 |
31,951 | void main()
{
struct distance
{
float a[2], b[2], c[2];
float d;
}dis[55];
int n, i, j, k=0, r[55], t;
float x[11], y[11], z[11];
scanf("%d", &n);
for(i=0; i<n; i++)
scanf("%f%f%f", &x[i], &y[i], &z[i]);
for(i=0; i<n-1; i++)
for(j=i+1; j<n; j++)
{
dis[k].d=(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[0]=x[i]; dis[k].a[1]=x[j];
dis[k].b[0]=y[i]; dis[k].b[1]=y[j];
dis[k].c[0]=z[i]; dis[k].c[1]=z[j];
r[k]=k;
k++;
}
for(i=0; i<k-1; i++)
for(j=0; j<k-1-i; j++)
if(dis[r[j]].d<dis[r[j+1]].d)
{
t=r[j];
r[j]=r[j+1];
r[j+1]=t;
}
for(i=0; i<k; i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", (int)dis[r[i]].a[0], (int)dis[r[i]].b[0], (int)dis[r[i]].c[0], (int)dis[r[i]].a[1], (int)dis[r[i]].b[1], (int)dis[r[i]].c[1], sqrt(dis[r[i]].d));
} | 64 |
31,952 | int x[11],y[11],z[11],cnt,n,dist[105];
int getdist(int i,int j){
return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);
}
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>x[i]>>y[i]>>z[i];
for(int i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
dist[++cnt]=getdist(i,j);
sort(dist+1,dist+1+cnt); //???? ????
for(int k=cnt;k>=1;k--)if(dist[k]!=dist[k-1]) //??????????????
for(int i=1;i<n;i++)
for(int j=i+1;j<=n;j++)
if(getdist(i,j)==dist[k])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i],y[i],z[i],x[j],y[j],z[j],(double)(sqrt(dist[k])));//???? ????????
return 0;
}
| 64 |
31,953 | /*??????
????????n??????10??,??n?????????,
???????????????????????????
????
????????????????n??????????????????(??????)?
????????0?100????????????????
????
?????n????????n*(n-1)/2???????????
(x1,y1,z1)-(x2,y2,z2)=??
???????????2?? */
int main()
{
int n;cin>>n;
int x[n+1],y[n+1],z[n+1];float dst[n*n]; int sma[n*n], lar[n*n];//dst=distance;sma??????lar?dst??,???????????
int count=0;
float t;
for( int i=1; i<=n; ++i )
{
cin>>x[i]>>y[i]>>z[i];
}
for( int e=1; e<=n; e++ )for(int e1=e+1; e1<=n; ++e1 )
{
++count;
sma[count]=e;lar[count]=e1;
dst[count]=sqrt((x[e]-x[e1])*(x[e]-x[e1])+(y[e]-y[e1])*(y[e]-y[e1])+(z[e]-z[e1])*(z[e]-z[e1]));
}
for(int e=1; e<=count-1; ++e )//???
for( int i=1; i<=count-e ;++i )
{
if ( dst[i]<dst[i+1] )
{
t=dst[i]; dst[i]=dst[i+1]; dst[i+1]=t;
t=sma[i]; sma[i]=sma[i+1]; sma[i+1]=(int)t;
t=lar[i]; lar[i]=lar[i+1]; lar[i+1]=(int)t;
}
}
for ( int e=1; e<=count ; ++e )
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[sma[e]],y[sma[e]],z[sma[e]],x[lar[e]],y[lar[e]],z[lar[e]],dst[e]);
return 0;
} | 64 |
31,954 | 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]);
}
}
| 64 |
31,955 | //Pat.X
int main()
{
int n; //????
int i,j,k,p; //??????
int x,y,z; //?????
int m; //????????
scanf("%d",&n);
m=n*(n-1)/2; //????????
double c[m],t,t0; //??????????????????
int a[n][3]; //?????????
double b[n][n]; //???????????????????????????
for(i=0;i<n;i++) //????
{
scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
}
k=0;
for(i=0;i<n-1;i++) //????
{
for(j=i+1;j<n;j++)
{
x=a[i][0]-a[j][0];
y=a[i][1]-a[j][1];
z=a[i][2]-a[j][2];
b[i][j]=sqrt(x*x+y*y+z*z);
c[k]=b[i][j];
k++;
}
}
for(i=k-1;i>0;i--) //????
{
for(j=0;j<i;j++)
{
if(c[j]<c[j+1])
{
t=c[j];
c[j]=c[j+1];
c[j+1]=t;
}
}
}
t0=c[0]+1; //????
for(i=0;i<k;i++) //??????
{
if(c[i]==t0)
continue;
if(c[i]!=t0){ //????????????????????
t0=c[i];
for(j=0;j<n-1;j++)
{
for(p=j+1;p<n;p++)
{
if(b[j][p]==c[i])
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[j][0],a[j][1],a[j][2],a[p][0],a[p][1],a[p][2],b[j][p]);
}
}
}
}
}
return 0;
} | 64 |
31,956 | void main()
{
int n,a[10][3],i,j,x[100][2],k=0,s;
double d[100],t;
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]=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])));
x[k][0]=i;x[k][1]=j;
k++;
}
for(i=0;i<k;i++)
for(j=0;j<k-i-1;j++)
if(d[j]<d[j+1]) {t=d[j];d[j]=d[j+1];d[j+1]=t;s=x[j][0];x[j][0]=x[j+1][0];x[j+1][0]=s;s=x[j][1];x[j][1]=x[j+1][1];x[j+1][1]=s;}
for(i=0;i<n*(n-1)/2;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[x[i][0]][0],a[x[i][0]][1],a[x[i][0]][2],a[x[i][1]][0],a[x[i][1]][1],a[x[i][1]][2],d[i]);
}
| 64 |
31,957 | main()
{
int a[10],b[10],c[10];
int i,j,k,n,t;
float w;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&a[i],&b[i],&c[i]);
struct px
{
float d;
int p,q,r;
int x,y,z;
};
struct px m[45];
k=0;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
m[k].d=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]));
m[k].p=a[i];
m[k].q=b[i];
m[k].r=c[i];
m[k].x=a[j];
m[k].y=b[j];
m[k++].z=c[j];
}
}
for(i=0;i<n*(n-1)/2-1;i++)
{
for(j=0;j<n*(n-1)/2-i;j++)
{
if(m[j].d<m[j+1].d)
{
w=m[j].d;
m[j].d=m[j+1].d;
m[j+1].d=w;
t=m[j].p;
m[j].p=m[j+1].p;
m[j+1].p=t;
t=m[j].q;
m[j].q=m[j+1].q;
m[j+1].q=t;
t=m[j].r;
m[j].r=m[j+1].r;
m[j+1].r=t;
t=m[j].x;
m[j].x=m[j+1].x;
m[j+1].x=t;
t=m[j].y;
m[j].y=m[j+1].y;
m[j+1].y=t;
t=m[j].z;
m[j].z=m[j+1].z;
m[j+1].z=t;
}
}
}
for(i=0;i<n*(n-1)/2;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",m[i].p,m[i].q,m[i].r,m[i].x,m[i].y,m[i].z,m[i].d);
} | 64 |
31,958 | int main()
{
int n,i,j=0,k,r,g,o,l;
int x[100],y[100],z[100];
int q[100],w[100];
double s[450],e;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
for(k=0;k<n-1;k++){
for(i=k+1;i<n;i++){
s[j]=1.0*pow((x[k]-x[i]),2)+pow((y[k]-y[i]),2)+pow((z[k]-z[i]),2);
s[j]=sqrt(s[j]);
q[j]=k;
w[j]=i;
j++;
}
}
for(g=1;g<=j;g++){
for(r=0;r<j-g;r++){
if(s[r]<s[r+1]){
e=s[r+1];
s[r+1]=s[r];
s[r]=e;
o=q[r+1];
q[r+1]=q[r];
q[r]=o;
l=w[r+1];
w[r+1]=w[r];
w[r]=l;
}
}
}
for(r=0;r<=j-1;r++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[q[r]],y[q[r]],z[q[r]],x[w[r]],y[w[r]],z[w[r]],s[r]);
}
return 0;
} | 64 |
31,959 | int read();
void calculate();
void sort();
double sqr(double p);
int print();
int x[100],y[100],z[100],n;
double a[100][100];
int main()
{
read();
calculate();
print();
return 0;
}
int read()
{
int i;
scanf("%d",&n);
for (i=1;i<=n;i++)
scanf ("%d%d%d",&x[i],&y[i],&z[i]);
return 0;
}
void calculate()
{
int i,j;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
a[i][j]=sqr((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
return;
}
int print()
{
int i,j,k,l,p;
double max;
p=n*(n-1)/2;
while (p>0)
{
max=-1;
for (i=1;i<n;i++)
for(j=n;j>i;j--)
{
if (max<a[i][j])
{
max=a[i][j];
k=i;
l=j;
}
else if (max==a[i][j])
{
if (k>i) {
k=i;
l=j;
}
else if (k==i&&l>j)
{
l=j;
}
}
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[k],y[k],z[k],x[l],y[l],z[l],a[k][l]);
a[k][l]=-100;
p--;
}
return 0;
}
double sqr(double p)
{
double x1,x2;
x2=p;
x1=1.0;
while (fabs(x2-x1)>1e-10)
{
x1=x2;
x2=(x1+p/x1)/2;
}
return x2;
}
| 64 |
31,960 |
int main(){
int n,x[10],y[10],z[10],xx1[50],yy1[50],zz1[50],xx2[50],yy2[50],zz2[50],i,t,k=0,e;
double j[10][10],jj[50],f;
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(t=0;t<n;t++){
j[i][t]=sqrt((x[i]-x[t])*(x[i]-x[t])+(y[i]-y[t])*(y[i]-y[t])+(z[i]-z[t])*(z[i]-z[t]));
}
}
for(i=0;i<n;i++){
for(t=i+1;t<n;t++){
jj[k]=j[i][t];
xx1[k]=x[i];
xx2[k]=x[t];
yy1[k]=y[i];
yy2[k]=y[t];
zz1[k]=z[i];
zz2[k]=z[t];
k++;
}
}
for(i=1;i<=k+1;i++){
for(t=0;t<k-1;t++){
if(jj[t]<jj[t+1]){
f=jj[t+1];
jj[t+1]=jj[t];
jj[t]=f;
e=xx1[t+1];
xx1[t+1]=xx1[t];
xx1[t]=e;
e=yy1[t+1];
yy1[t+1]=yy1[t];
yy1[t]=e;
e=zz1[t+1];
zz1[t+1]=zz1[t];
zz1[t]=e;
e=xx2[t+1];
xx2[t+1]=xx2[t];
xx2[t]=e;
e=yy2[t+1];
yy2[t+1]=yy2[t];
yy2[t]=e;
e=zz2[t+1];
zz2[t+1]=zz2[t];
zz2[t]=e;
}
}
}
for(i=0;i<k;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",xx1[i],yy1[i],zz1[i],xx2[i],yy2[i],zz2[i],jj[i]);
}
return 0;
} | 64 |
31,961 |
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 |
31,962 |
int main()
{
int n , c ;
cin >> n ; //???
int x[n] , y[n] , z[n] ;
c = n * ( n - 1 ) / 2 ; //????
int a[c] , b[c] ; // ????????????????????
double l[c] ; //????
for( int i = 0 ; i < n ; i ++ ) //??
{
cin >> x[i] >> y[i] >> z[i] ;
}
c = -1 ;
for( int i = 0 ; i < n - 1 ; i ++ ) //???????
for( int j = i + 1 ; j < n ; j ++ )
{
c ++ ;
a[c] = i ;
b[c] = j ;
l[c] = sqrt( ( x[i] - x[j] ) * ( x[i] - x[j] ) +
( y[i] - y[j] ) * ( y[i] - y[j] ) + ( z[i] - z[j] ) * ( z[i] - z[j] ) ) ;
}
double t1 = 0 ;
int t = 0 ;
for( int i = 0 ; i <= c ; i ++ ) //??????????????
for( int j = 0 ; j <= c - 1 - i ; j ++ )
{
if( l[j] < l[j+1] )
{
t1 = l[j] ; l[j] = l[j+1] ; l[j+1] = t1 ;
t = a[j] ; a[j] = a[j+1] ; a[j+1] = t ;
t = b[j] ; b[j] = b[j+1] ; b[j+1] = t ;
}
}
cout << fixed << setprecision(2) ; //????????
for( int i = 0 ; i <= c ; i ++ )
{
cout << "(" << x[a[i]] << "," << y[a[i]] << "," << z[a[i]] << ")-("
<< x[b[i]] << "," << y[b[i]] << "," << z[b[i]] << ")="
<< l[i] << endl ;
}
return 0 ;
}
| 64 |
31,963 | int main(){
int n,i,j,g,k,a[50],b[50],x[10],y[10],z[10],w,q;
double s[50],e;
k=-1;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d",&x[i],&y[i],&z[i]);
}
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
k++;
s[k]= sqrt(pow((x[i]-x[j]),2)+pow((y[i]-y[j]),2)
+pow((z[i]-z[j]),2));
a[k]=i;
b[k]=j;
}
}
for(i=1;i<=n*(n-1)/2;i++){
for(k=0;k<n*(n-1)/2-i;k++){
if(s[k]<s[k+1]){
e=s[k];
s[k]=s[k+1];
s[k+1]=e;
g=a[k];
a[k]=a[k+1];
a[k+1]=g;
g=b[k];
b[k]=b[k+1];
b[k+1]=g;
}
}
}
for(k=0;k<n*(n-1)/2;k++){
q=a[k];
w=b[k];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[q],y[q],z[q],x[w],y[w],z[w],s[k]);
}
return 0;
}
| 64 |
31,964 | /*
* structure_4.cpp
*
* Created on: 2010-12-29
* Author: ???
* ??? ????
*/
int main(){
int n,i,j,num;
cin>>n;
struct point{ //??????
int x;
int y;
int z;
} p[100];
for(i=0;i<n;i++) //????????
cin>>p[i].x>>p[i].y>>p[i].z;
struct distance{ //??????????
double dis;
int i;
int j;
} d[5000],temp;
for(i=0,num=0;i<n-1;i++) //?????
for(j=i+1;j<n;j++,num++){
d[num].dis=sqrt(pow(p[i].x-p[j].x,2.0)+pow(p[i].y-p[j].y,2.0)+pow(p[i].z-p[j].z,2.0));
d[num].i=i;
d[num].j=j;
}
for(i=0;i<num-1;i++) //?????
for(j=0;j<num-i-1;j++){
if(d[j].dis<d[j+1].dis){
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
}
}
for(i=0;i<num;i++) //????
cout<<'('<<p[d[i].i].x<<','<<p[d[i].i].y<<','<<p[d[i].i].z<<")-("<<p[d[i].j].x<<','<<p[d[i].j].y<<','<<p[d[i].j].z<<")="<<fixed<<setprecision(2)<<d[i].dis<<endl;
return 0;
}
| 64 |
31,965 | 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 |
31,966 | 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 |
31,967 |
int main()
{
int i, j, k, l = 0, num;
double temp = 0;
int pos[100][3];
double distance[9900] = {0};
int latter[9900], former[9900];
cin >> num;
for (i = 0; i < num; i++)
{
for(j = 0; j < 3; j++)
{
cin >> pos[i][j];
}
}
for (i = 0; i < num; i++)
{
for (j = i + 1; j < num; j++)
{
for (k = 0; k < 3; k++)
{
former[l] = i;
latter[l] = j;
distance[l] += (pos[i][k] - pos[j][k]) * (pos[i][k] - pos[j][k]);
}
distance[l] = sqrt (distance[l]);
l++;
}
}
l = (num - 1) * num / 2;
for (i = 0; i < l - 1; i++)
{
for (j = 0; j < l - i - 1; j++)
{
if (distance[j] < distance[j + 1])
{
temp = distance[j];
distance[j] = distance[j + 1];
distance[j + 1] = temp;
temp = latter[j];
latter[j] = latter[j + 1];
latter[j + 1] = temp;
temp = former[j];
former[j] = former[j + 1];
former[j + 1] = temp;
}
}
}
for (i = 0; i < l; i++)
{
cout << "(" << pos[former[i]][0] << "," << pos[former[i]][1]
<< "," << pos[former[i]][2] <<")-(" << pos[latter[i]][0]
<< "," << pos[latter[i]][1] << "," << pos[latter[i]][2]
<<")=" << fixed << setprecision(2) << distance[i] << endl;
}
return 0;
}
| 64 |
31,968 | 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 |
31,969 | int main()
{
int n,i,m,x[100],y[100],z[100],r[100],t[100],a,b,k,c,d,p;
double q[100],e;
m=0;
scanf("%d", &n);
for(i=0;i<n;i++){
scanf("%d%d%d", &x[i], &y[i], &z[i]);}
for(k=0;k<n;k++){
for(i=k+1;i<n;i++){
q[m]=sqrt(1.0*(x[i]-x[k])*(x[i]-x[k])+1.0*(y[i]-y[k])*(y[i]-y[k])+1.0*(z[i]-z[k])*(z[i]-z[k]));
r[m]=k;
t[m]=i;
m++;}
}
p=n*(n-1)/2;
for(a=1;a<p+1;a++){
for(m=0;m<p-a;m++){
if(q[m]<q[m+1]){
e=q[m+1];
q[m+1]=q[m];
q[m]=e;
b=r[m+1];
r[m+1]=r[m];
r[m]=b;
b=t[m+1];
t[m+1]=t[m];
t[m]=b;}
}
}
c=0;
d=0;
for(m=0;m<p;m++){
c=r[m];
d=t[m];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n", x[c], y[c], z[c], x[d], y[d], z[d], q[m]);}
return 0;
} | 64 |
31,970 | 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 |
31,971 | double jl(int ma,int mb,int mc,int md,int me,int mf);
int main(){
int a[max],b[max];
int i,k,n,j,h;
double t,s[max];
struct dian{
int x,y,z;
}d[max];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d%d%d",&(d[i].x),&(d[i].y),&(d[i].z));
}
for(k=0,j=0;j<n;j++){
for(i=j+1;i<n;i++,k++){
s[k]=jl(d[i].x,d[i].y,d[i].z,d[j].x,d[j].y,d[j].z);
a[k]=i;
b[k]=j;
}
}
for(k=1;k<=n*(n-1)/2;k++){
for(i=0;i<n*(n-1)/2-k;i++){
if(s[i+1]>s[i]){
t=s[i+1];
s[i+1]=s[i];
h=a[i];
a[i]=a[i+1];
a[i+1]=h;
s[i]=t;
j=b[i];
b[i]=b[i+1];
b[i+1]=j;
}
}
}
for(i=0;i<n*(n-1)/2;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",d[b[i]].x,d[b[i]].y,d[b[i]].z,d[a[i]].x,d[a[i]].y,d[a[i]].z,s[i]);
}
return 0;
}
double jl(int ma,int mb,int mc,int md,int me,int mf){
double l;
l=sqrt((double)(ma-md)*(ma-md)+(mb-me)*(mb-me)+(mc-mf)*(mc-mf));
return l;
}
| 64 |
31,972 | struct distance
{
int sp1x;
int sp1y;
int sp1z;
int sp2x;
int sp2y;
int sp2z;
double dis;
} dis[999999],temp;
int main()
{
int n,spot[9999][3]={0},t=0;
cin>>n;
for (int i=0;i<n;i++)
cin>>spot[i][0]>>spot[i][1]>>spot[i][2];
for (int i=0;i<n-1;i++)
for (int j=i+1;j<n;j++)
{
dis[t].sp1x=spot[i][0];
dis[t].sp1y=spot[i][1];
dis[t].sp1z=spot[i][2];
dis[t].sp2x=spot[j][0];
dis[t].sp2y=spot[j][1];
dis[t].sp2z=spot[j][2];
dis[t].dis=sqrt(pow(spot[i][0]-spot[j][0],2.0) + pow(spot[i][1]-spot[j][1],2.0) + pow(spot[i][2]-spot[j][2],2.0));
t++;
}
for (int i=0;i<=t-2;i++)
for (int j=0;j<=t-2-i;j++)
if (dis[j].dis<dis[j+1].dis)
{
temp=dis[j];
dis[j]=dis[j+1];
dis[j+1]=temp;
}
for (int i=0;i<t;i++)
cout<<"("<<dis[i].sp1x<<","<<dis[i].sp1y<<","<<dis[i].sp1z<<")-("<<dis[i].sp2x<<","<<dis[i].sp2y<<","<<dis[i].sp2z<<")="
<<fixed<<setprecision(2)<<dis[i].dis<<endl;
return 0;
} | 64 |
31,973 | int main()
{
int x[10],y[10],z[10];
int i,j=1,n,p,q,k=0,m;
double d[10][10],max;
scanf("%d\n",&n);
for(i=0;i<n;i++)
scanf("%d%d%d",&x[i],&y[i],&z[i]);
i=0;
if(n==2)
{
p=i;q=j;
max=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]));
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p],y[p],z[p],x[q],y[q],z[q],max);
return 0;
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
d[i][j]=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]));
}
}
max=d[0][1];
m=n*(n-1)/2;
while(k<m)
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(max<d[i][j])
{
max=d[i][j];
p=i;
q=j;
}
}
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p],y[p],z[p],x[q],y[q],z[q],max);
d[p][q]=0.0;
k++;
max=0;
}
return 0;
}
| 64 |
31,974 | struct num1
{
int a;
int b;
int c;
} num1[100];
struct num
{
int x1;
int x2;
int x3;
int x11;
int x12;
int x13;
int l1;
int l2;
float sum;
}num[5010],k;
int main()
{ int t = 0,n,i,j,sum;
scanf("%d",&n);
for( i = 1; i <= n ;i ++)
scanf("%d %d %d",&num1[i].a,&num1[i].b,&num1[i].c);
for( i = 1; i <= n;i ++)
{
for( j = i+1; j <= n ;j++ )
{
num[t].x1 = num1[i].a;
num[t].x2 = num1[i].b;
num[t].x3 = num1[i].c;
num[t].x11 = num1[j].a;
num[t].x12 = num1[j].b;
num[t].x13 = num1[j].c;
num[t].sum = (num[t].x1-num[t].x11)*(num[t].x1-num[t].x11)+(num[t].x2-num[t].x12)*(num[t].x2-num[t].x12)+(num[t].x3-num[t].x13)*(num[t].x3-num[t].x13);
num[t].l1 = i;
num[t].l2 = j;
t ++ ;
}
}
for( i = 0;i <t ;i++ )
{for ( j = i ;j <t;j++ )
{ if(num[i].sum<num[j].sum)
{ k = num[i];
num[i] = num[j];
num[j] = k;
}
}
}
for( i = 0;i <t ;i++ )
{for ( j = i ;j <t;j++ )
{ if((num[i].sum==num[j].sum)&&((num[i].l1>num[j].l1)||((num[i].l1==num[j].l1)&&(num[i].l2>num[j].l2))))
{ k = num[i];
num[i] = num[j];
num[j] = k;
}
}
}
for( i = 0 ;i < t ;i++ )
{ printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",num[i].x1,num[i].x2,num[i].x3,num[i].x11,num[i].x12,num[i].x13,sqrt(num[i].sum));}
}
| 64 |
31,975 | double num[46][8];
struct node
{
int a,b,c;
int arr[11];
};
struct node arr[11];
int main()
{
int i,n,j,m;
struct node arr[11];
while(scanf("%d",&n)!=EOF)
{
memset(num,0,sizeof(num));
memset(arr,0,sizeof(arr));
for(i=0;i<n;i++)
scanf("%d %d %d",&arr[i].a,&arr[i].b,&arr[i].c);
int h=0,k=0;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
double aa,bb,cc,dd;
aa=pow((double) (arr[i].a-arr[j].a),(int) 2);
bb=pow((double) (arr[i].b-arr[j].b),(int) 2);
cc=pow((double) (arr[i].c-arr[j].c),(int) 2);
dd= sqrt((double)(aa+bb+cc));
num[h][0]=arr[i].a;
num[h][1]=arr[i].b;
num[h][2]=arr[i].c;
num[h][3]=arr[j].a;
num[h][4]=arr[j].b;
num[h][5]=arr[j].c;
num[h][6]=dd;
num[h][7]=k;
k++;
h++;
}
for(i=0;i<h-1;i++)
for(j=i+1;j<h;j++)
if(num[i][6]<=num[j][6])
{
double d1=0;
for(m=0;m<=6;m++)
{
d1=num[i][m];
num[i][m]=num[j][m];
num[j][m]=d1;
}
}
for(i=0;i<h-1;i++)
for(j=i+1;j<h;j++)
if(num[i][6]==num[j][6])
{
if(num[i][7]<num[j][7])
{
double d1=0;
for(m=0;m<=7;m++)
{
d1=num[i][m];
num[i][m]=num[j][m];
num[j][m]=d1;
}
}
}
for(i=0;i<h;i++)
printf("(%.f,%.f,%.f)-(%.f,%.f,%.f)=%.2f\n",num[i][0],num[i][1],num[i][2],num[i][3],
num[i][4],num[i][5],num[i][6]);
}
return 0;
} | 64 |
31,976 | 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 |
31,977 | main()
{
struct B
{int a;int b;int c;int d;int e;int f;float g;}B[45];
int n,A[10][3],i,j,p=0,q=0;
float c[45];
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<3;j++)
scanf("%d",&A[i][j]);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
B[p].a=A[i][0];
B[p].b=A[i][1];
B[p].c=A[i][2];
B[p].d=A[j][0];
B[p].e=A[j][1];
B[p].f=A[j][2];
B[p].g=(float)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]));
p++;
}
for(i=0;i<p;i++)
{
c[i]=0;
if(i==0){for(j=0;j<p;j++)if(B[j].g>c[i]) {c[i]=B[j].g;q++;}}
else
for(j=0;j<p;j++)
{
if(c[i]<B[j].g&&B[j].g<c[i-1])
{c[i]=B[j].g;q++;}
}
}
int z=0;
for(i=0;i<q;i++)
for(j=0;j<p;j++)
{ if(z==n*(n-1)/2)break;
if(B[j].g==c[i])
{z++;printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",B[j].a,B[j].b,B[j].c,B[j].d,B[j].e,B[j].f,B[j].g);
}
}
} | 64 |
31,978 | /**
* @file C12Q4.cpp
* @author ???
* @date 2013-12-14
* @description
* ??????:????
*/
typedef struct node
{
int x,y,z;
}node;
typedef struct distance
{
node*pn1,*pn2;
double v;
}dis;
int main()
{
int n;
node ns[MAX];
dis ds[MAX*MAX];
cin >> n;
for(int i = 0 ; i < n ; i++)
{
cin >> ns[i].x >> ns[i].y >> ns[i].z;
}
int p = 0 ;
for(int i = 0 ; i < n ; i++)
for(int j = i+1 ; j < n ; j++)
{
ds[p].pn1 = ns+i;
ds[p].pn2 = ns+j;
ds[p].v = sqrt((ns[i].x - ns[j].x)*(ns[i].x - ns[j].x)+(ns[i].y - ns[j].y)*(ns[i].y - ns[j].y)
+(ns[i].z - ns[j].z)*(ns[i].z - ns[j].z));
p++;
}
for(int i = 0 ; i < p ; i++)
{
for(int j = p-1; j > i ; j--)
{
if (ds[j].v > ds[j-1].v)
{
dis tmp = ds[j];
ds[j] = ds[j-1];
ds[j-1] = tmp;
}
}
}
for(int i = 0 ; i < p ; i ++)
{
cout << '(' <<ds[i].pn1 ->x << ',' << ds[i].pn1 ->y << ',' << ds[i].pn1 ->z << ')' << '-' ;
cout << '(' <<ds[i].pn2 ->x << ',' << ds[i].pn2 ->y << ',' << ds[i].pn2 ->z << ')' << '=' ;
cout << setprecision(2) << fixed <<ds[i].v << endl;
}
return 0;
} | 64 |
31,979 | 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 |
31,980 | 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 |
31,981 | int main()
{
int n;
double x[11], y[11], z[11], s[11][11];
cin >> n;
for(int i = 1; i <= n; i++)
cin >> x[i] >> y[i] >> z[i];
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
{
s[i][j] = (x[i]-x[j])*(x[i]- x[j]) + (y[i]-y[j])*(y[i]-y[j]) + (z[i]-z[j])*(z[i]-z[j]);
s[i][j] = sqrt(s[i][j]);
}
}
for(int k = 1; k <= n * (n-1) / 2; k++)
{
double max = 0;
int t1 = 0, t2 = 0;
for(int i = 1; i <= n; i++)
{
for(int j = i + 1; j <= n; j++)
{
if(s[i][j] > max )
{
// cout << i<<" "<<j<<" : "<<s[i][j] << " & "<<max <<endl;
max = s[i][j];
t1 = i;
t2 = j;
}
}
}
cout << "(" << x[t1] << "," << y[t1] << "," << z[t1] << ")-(" << x[t2] << "," << y[t2] << "," << z[t2] << ")=" ;
printf( "%.2lf\n", s[t1][t2]);
s[t1][t2] = 0;
}
return 0;
} | 64 |
31,982 | 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 |
31,983 | double s[10][10];
int c[2];
int min(int n)
{int i,j;
double m=-1;
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
if (s[i][j]>m) {c[0]=i;c[1]=j;m=s[i][j];}
}
int main()
{int n,i,j,ll;
scanf("%d",&n);
int x[n],y[n],z[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++)
{s[i][j]=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]);
s[i][j]=sqrt(s[i][j]);
}
for (i=0;i<(n-1)*n/2;i++)
{min(n);
printf ("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[c[0]],y[c[0]],z[c[0]],x[c[1]],y[c[1]],z[c[1]],s[c[0]][c[1]]);
s[c[0]][c[1]]=-1;
}
return 0;
}
| 64 |
31,984 | int main(){
int x[10],y[10],z[10];
int n,i;
scanf("%d",&n);
int max,k=0;
max=n*(n-1)/2;
int MAX[45*45],MAX2[45*45];
int c;
double di[45][45],sz[45]={0.00};
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
for(i=0;i<n-1;i++){
for(k=1;k+i<n;k++){
di[i][i+k]=sqrt((x[i]-x[i+k])*(x[i]-x[i+k])+(y[i]-y[i+k])*(y[i]-y[i+k])+(z[i]-z[i+k])*(z[i]-z[i+k]));}
}
for(c=0;c<max;c++){for(i=0;i<n-1;i++){
for(k=1;k+i<n;k++){if(c==0){if(sz[c]<di[i][i+k]){MAX[c]=i;MAX2[c]=i+k;sz[c]=di[i][i+k];}}
else if(sz[c]<di[i][i+k]&&di[i][i+k]<sz[c-1]){MAX[c]=i;MAX2[c]=i+k;sz[c]=di[i][i+k];}
else if(sz[c]<di[i][i+k]&&di[i][i+k]==sz[c-1]){if(i>MAX[c-1]){MAX[c]=i;MAX2[c]=i+k;sz[c]=di[i][i+k];}else if(i==MAX[c-1]){if(i+k>MAX2[c-1]){MAX[c]=i;MAX2[c]=i+k;sz[c]=di[i][i+k];}}
}}}}
for(c=0;c<max;c++){printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[MAX[c]],y[MAX[c]],z[MAX[c]],x[MAX2[c]],y[MAX2[c]],z[MAX2[c]],sz[c]);}
return 0;
} | 64 |
31,985 |
int main(){
int n,i,j,k,l;
int x[20],y[20],z[20];
struct
{
int x1,y1,z1;
int x2,y2,z2;
double dis;
}
out[50],h;
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;i++)
{
for(j=i+1;j<n;j++)
{
out[k].x1=x[i];
out[k].y1=y[i];
out[k].z1=z[i];
out[k].x2=x[j];
out[k].y2=y[j];
out[k].z2=z[j];
k++;
}
}
for(i=0;i<n*(n-1)/2;i++)
{
out[i].dis=sqrt((out[i].x1-out[i].x2)*(out[i].x1-out[i].x2)
+(out[i].y1-out[i].y2)*(out[i].y1-out[i].y2)
+(out[i].z1-out[i].z2)*(out[i].z1-out[i].z2));
}
for(i=0;i<n*(n-1)/2;i++)
{
for(j=n*(n-1)/2-1;j>i;j--)
{
if(out[j].dis>out[j-1].dis)
{
h=out[j];
out[j]=out[j-1];
out[j-1]=h;
}
}
}
for(i=0;i<n*(n-1)/2;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",out[i].x1,
out[i].y1,out[i].z1,out[i].x2,out[i].y2,out[i].z2
,out[i].dis);
}
return 0;
}
| 64 |
31,986 | int main()
{
int n;
cin>>n;
int x[n],y[n],z[n],p,q;
float d[n][n-1],t;
float a[n*(n-1)/2];
int k=0;
int b[n*(n-1)/2],c[n*(n-1)/2];
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++)
{
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]));
a[k]=d[i][j];b[k]=i;c[k]=j;
k++;
}
for(int i=1;i<n*(n-1)/2;i++)
for(int j=0;j<n*(n-1)/2-i;j++)
{
if(a[j]<a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
p=b[j];
b[j]=b[j+1];
b[j+1]=p;
q=c[j];
c[j]=c[j+1];
c[j+1]=q;
}
}
for(int i=0;i<k;i++)
{
cout<<"("<<x[b[i]]<<","<<y[b[i]]<<","<<z[b[i]]<<")-"<<"("<<x[c[i]]<<","<<y[c[i]]<<","<<z[c[i]]<<")="<<fixed<<setprecision(2)<<a[i]<<endl;
}
return 0;
} | 64 |
31,987 | int main(){
int x[10],y[10],z[10],n,i,j,c,maxi,maxj;
float s[10][10],max;
max=0.0f;
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++){
s[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(c=0;c<(n*(n-1)/2);c++){
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(s[i][j]>max){
max=s[i][j];
maxi=i;
maxj=j;
}
}
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[maxi],y[maxi],z[maxi],x[maxj],y[maxj],z[maxj],max);
s[maxi][maxj]=0.0f;
max=0.0f;
maxi=i;
maxj=j;
}
return 0;
} | 64 |
31,988 | //********************************
//*??????? **
//*?????? 1200012839 **
//*???2012.12.10 **
//********************************
int main()
{
int n, k = 0;
cin >> n;
struct point
{
int x;
int y;
int z;
}point[n];
struct distance
{
int pointa;
int pointb;
double d;
}dis[4950],temp;
for (int i = 0; i < n; i++)
{
cin >> point[i].x >> point[i].y >> point[i].z;
}
for (int i=0;i<n-1;i++)
{
for (int j=i+1;j<n;j++)
{
dis[k].d = 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));
dis[k].pointa = i;
dis[k].pointb = j;
k++;
}
}
for (int i = 0; i < n * (n - 1) / 2 - 1; i++)
{
for (int j = i + 1; j < n * (n - 1) / 2; j++)
{
if (dis[i].d < dis[j].d)
{
temp = dis[i];
dis[i] = dis[j];
dis[j] = temp;
}
if (dis[i].d == dis[j].d && (dis[i].pointa > dis[j].pointa || dis[i].pointb > dis[j].pointb))
{
temp = dis[i];
dis[i] = dis[j];
dis[j] = temp;
}
}
}
for (int i = 0; i < n * (n - 1) / 2; i++)
{
cout << "(" << point[dis[i].pointa].x << "," << point[dis[i].pointa].y << "," << point[dis[i].pointa].z << ")" << "-"
<< "(" << point[dis[i].pointb].x << "," << point[dis[i].pointb].y << "," << point[dis[i].pointb].z << ")" << "="
<< fixed << setprecision(2) << dis[i].d << endl;
}
return 0;
} | 64 |
31,989 | //******************************************
//*???????.cpp **
//*??: ?? 1100012808 **
//*???2011.12.07 **
//******************************************
double d[45];
int n;
void maopaopaixu(double d[])
{
int i, j;
double t;
for (i = 0; i < n * (n - 1) / 2; i++)
{
for (j = 0; j < n * (n - 1) / 2 - i; j++)
{
if (d[j] < d[j + 1])
{
t = d[j];
d[j] = d[j + 1];
d[j + 1] = t;
}
}
}
}
int main() //???
{ //?????
int i, j, k = 0, flag, a[11][3] = {0}, g[10][10] = {0};
double b[10][10] = {0.0};
cin >> n;
for (i = 0; i < n; i++)
{
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
d[k] = sqrt((a[i][1] - a[j][1]) * (a[i][1] - a[j][1]) +
(a[i][0] - a[j][0]) *(a[i][0] - a[j][0]) +
(a[i][2] - a[j][2]) * (a[i][2] - a[j][2]));
b[i][j] = d[k];
k++;
}
}
maopaopaixu(d);
for (k = 0; k < n * (n - 1) / 2; k++)
{
flag = 0;
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
if (fabs(b[i][j] - d[k]) < 0.00000001 && g[i][j] == 0)
{
cout << "(" << a[i][0] << "," <<
a[i][1] << "," <<
a[i][2] << ")" << "-" << "(" <<
a[j][0] << "," <<
a[j][1] << "," <<
a[j][2] << ")" << "=" << fixed <<
setprecision(2) << d[k] << endl;
flag = 1;
g[i][j] = 1;
break;
}
}
if (flag)
break;
}
}
return 0;
} //?????
| 64 |
31,990 | // ?????? ???1000010500
// ????
// 2010-12-20
struct point // ?????
{
int x,y,z;
}dot[10];
int main()
{
int n,i,j,k,p,q;
double distance[10][10],t,max,min = 200;
cin >> n;
for (i = 0;i < n;i++) // ????
cin >> dot[i].x >> dot[i].y >> dot[i].z;
for (i = 0;i < n - 1;i++) // ???i??j???
for (j = i + 1;j < n;j++)
{
distance[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));
// ??????????
min = (distance[i][j] < min) ? distance[i][j] : min;
}
for (k = 0;k < n * (n - 1) / 2;k++) // ?????????
{
max = min;
for (i = n - 2;i >= 0;i--)
for (j = n - 1;j >= i + 1;j--)
{
if (max <= distance[i][j])
{
max = distance[i][j];
p = i;
q = j;
}
}
cout << "(" << dot[p].x << "," << dot[p].y << "," << dot[p].z << ")-("
<< dot[q].x << "," << dot[q].y << "," << dot[q].z << ")="
<< fixed << setprecision(2)<< distance[p][q] << endl;
distance[p][q] = 0;
}
return 0;
}
| 64 |
31,991 | int main()
{
int n,i,j,k,p=0,q,r,e;
cin>>n;
float s,m1,m2,m3,m4,m5,m6,f,g;
float l[50];//??
float x[10];
float y[10];
float z[10];//??
float a1[50][2];
float a2[50][2];
float a3[50][2];
float b1[50][2];
float b2[50][2];
float b3[50][2];//????????
for(i=0;i<n;i++)
cin>>x[i]>>y[i]>>z[i];//??
for(j=0;j<n-1;j++)
{
for(k=j+1;k<n;k++)
{
l[p]=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]));
a1[p][0]=x[j];a2[p][0]=y[j];a3[p][0]=z[j];b1[p][0]=x[k];b2[p][0]=y[k];b3[p][0]=z[k];
a1[p][1]=j;a2[p][1]=j;a3[p][1]=j;b1[p][1]=k;b2[p][1]=k;b3[p][1]=k;
p=p+1;
}//????????
}
for(q=0;q<p-1;q++)
{
for(r=q+1;r<p;r++)
{
if(l[q]<l[r])
{
s=l[q];
l[q]=l[r];
l[r]=s;
f=a1[q][1];
a1[q][1]=a1[r][1];
a1[r][1]=f;
g=b1[q][1];
b1[q][1]=b1[r][1];
b1[r][1]=g;
m1=a1[q][0];
a1[q][0]=a1[r][0];
a1[r][0]=m1;
m2=a2[q][0];
a2[q][0]=a2[r][0];
a2[r][0]=m2;
m3=a3[q][0];
a3[q][0]=a3[r][0];
a3[r][0]=m3;
m4=b1[q][0];
b1[q][0]=b1[r][0];
b1[r][0]=m4;
m5=b2[q][0];
b2[q][0]=b2[r][0];
b2[r][0]=m5;
m6=b3[q][0];
b3[q][0]=b3[r][0];
b3[r][0]=m6;
}//??????
if(l[q]==l[r]&&a1[q][1]>=a1[r][1])
{
f=a1[q][1];
a1[q][1]=a1[r][1];
a1[r][1]=f;
g=b1[q][1];
b1[q][1]=b1[r][1];
b1[r][1]=g;
m1=a1[q][0];
m1=a1[q][0];
a1[q][0]=a1[r][0];
a1[r][0]=m1;
m2=a2[q][0];
a2[q][0]=a2[r][0];
a2[r][0]=m2;
m3=a3[q][0];
a3[q][0]=a3[r][0];
a3[r][0]=m3;
m4=b1[q][0];
b1[q][0]=b1[r][0];
b1[r][0]=m4;
m5=b2[q][0];
b2[q][0]=b2[r][0];
b2[r][0]=m5;
m6=b3[q][0];
b3[q][0]=b3[r][0];
b3[r][0]=m6;
}
if(l[q]==l[r]&&b1[q][1]>=b1[r][1])
{
f=a1[q][1];
a1[q][1]=a1[r][1];
a1[r][1]=f;
g=b1[q][1];
b1[q][1]=b1[r][1];
b1[r][1]=g;
m1=a1[q][0];
m1=a1[q][0];
a1[q][0]=a1[r][0];
a1[r][0]=m1;
m2=a2[q][0];
a2[q][0]=a2[r][0];
a2[r][0]=m2;
m3=a3[q][0];
a3[q][0]=a3[r][0];
a3[r][0]=m3;
m4=b1[q][0];
b1[q][0]=b1[r][0];
b1[r][0]=m4;
m5=b2[q][0];
b2[q][0]=b2[r][0];
b2[r][0]=m5;
m6=b3[q][0];
b3[q][0]=b3[r][0];
b3[r][0]=m6;}
//???????????
}
}
for(e=0;e<p;e++)
{
cout<<"("<<a1[e][0]<<","<<a2[e][0]<<","<<a3[e][0]<<")-("<<b1[e][0]<<","<<b2[e][0]<<","<<b3[e][0]<<")=";
printf("%.2f\n",l[e]);//??
}
getchar();
getchar();
return 0;
} | 64 |
31,992 | //**********************************************************
//* ?????1.cpp *
//* ??????1200012906 *
//* ???2012?12?10? *
//* ????????? *
//**********************************************************
struct
{
int id;
int x1;
int y1;
int z1;
int x2;
int y2;
int z2;
double distance;
}data[55], t;
int main()
{
int n, x[10], y[10], z[10], 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++)
{
data[k].id = k;
data[k].x1 = x[i];
data[k].y1 = y[i];
data[k].z1 = z[i];
data[k].x2 = x[j];
data[k].y2 = y[j];
data[k].z2 = z[j];
data[k].distance = pow(x[i] - x[j], 2.0) + pow(y[i] - y[j], 2.0) + pow(z[i] - z[j], 2.0);
k++; //k???????????
}
for(i = 0; i < k - 1; i++)
for(j = 0; j < k - i - 1; j++)
{
if (data[j].distance < data[j + 1].distance)
{ //??????
t = data[j];
data[j] = data[j + 1];
data[j + 1] = t;
}
}
for(i = 0; i < k; i++)
{
cout << "(" << data[i].x1 << "," << data[i].y1 << "," << data[i].z1 << ")-(";
cout << data[i].x2 << "," << data[i].y2 << "," << data[i].z2 << ")=";
cout << fixed << setprecision(2) << sqrt(data[i].distance) << endl;
}
return 0;
} | 64 |
31,993 | int main()
{
int n, l = 0;
struct point
{
int x;
int y;
int z;
}a[10];
struct distance
{
int m[3];
int n[3];
double dis;
}temp,b[100];
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i].x>>a[i].y>>a[i].z;
}
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
b[l].m[0] = a[i].x;
b[l].m[1] = a[i].y;
b[l].m[2] = a[i].z;
b[l].n[0] = a[j].x;
b[l].n[1] = a[j].y;
b[l].n[2] = a[j].z;
b[l].dis = sqrt( ( a[j].x - a[i].x ) * ( a[j].x - a[i].x ) + ( a[j].y - a[i].y ) * ( a[j].y - a[i].y ) + ( a[j].z - a[i].z ) * ( a[j].z - a[i].z ) );
l++;
}
}
for(int i=0;i<n*(n-1)/2-1;i++)
{
for(int j=0;j<n*(n-1)/2-1;j++)
{
if(b[j].dis<b[j+1].dis)
{
temp=b[j];
b[j]=b[j+1];
b[j+1]=temp;
}
}
}
for(int i=0;i<n*(n-1)/2;i++)
{
cout<<"("<<b[i].m[0]<<","<<b[i].m[1]<<","<<b[i].m[2]<<")-("
<<b[i].n[0]<<","<<b[i].n[1]<<","<<b[i].n[2]<<")="<<fixed<<setprecision(2)<<b[i].dis<<endl;
}
return 0;
}
| 64 |
31,994 | int main()
{
int x[100][30],i,j,k=0,m,n,p;
double s[1000],a;
scanf("%d",&n);
m=n*(n-1)/2;
for(i=0;i<n;i++){
for(j=0;j<3;j++){
scanf("%d",&x[i][j]);
}
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
s[k]=sqrt((pow(x[i][0]-x[j][0],2)+pow(x[i][1]-x[j][1],2)+pow(x[i][2]-x[j][2],2))*1.0);
k++;
}
}
for(i=1;i<k;i++){
for(j=0;j<k-i;j++){
if(s[j]>s[j+1]){
a=s[j];
s[j]=s[j+1];
s[j+1]=a;
}
}
}
s[k]=-1;
for(p=k-1;p>=0;p--){
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(s[p]!=s[p-1]){
if(sqrt((pow(x[i][0]-x[j][0],2)+pow(x[i][1]-x[j][1],2)+pow(x[i][2]-x[j][2],2))*1.0)==s[p])
{printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[i][0],x[i][1],x[i][2],x[j][0],x[j][1],x[j][2],s[p]);}}
}
}
}
return 0;
}
| 64 |
31,995 | int main(){
int n,i,j,c,d,s[10][3],k,f;
double a[10][10],e;
scanf("%d",&n);
for(i=0;i<n;i++){
for(j=0;j<3;j++){
scanf("%d",&s[i][j]);
}}
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
a[i][j]=sqrt(pow(s[i][0]-s[j][0],2)+pow(s[i][2]-s[j][2],2)+pow(s[i][1]-s[j][1],2));
}}
e=0;f=(n*n-n)/2;
for(k=1;k<=f;k++){
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(e<a[i][j]){
e=a[i][j];
c=i;
d=j;
}}}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",s[c][0],s[c][1],s[c][2],s[d][0],s[d][1],s[d][2],e);
e=0;
a[c][d]=0;
c=0;
d=0;
}
return 0;
}
| 64 |
31,996 | int main ()
{int n;
scanf ("%d",&n);
struct dot
{
int x,y,z;
double len[9];
}
dots[10];
for (int i1=0;i1<n;i1++)
{
scanf("%d%d%d",&dots[i1].x,&dots[i1].y,&dots[i1].z);
}
for (int i2=0;i2<n-1;i2++)
{
for (int i3=n-i2-2;i3>=0;i3--)
{
dots[i2].len[n-i2-2-i3]=(dots[i2].x-dots[n-i3-1].x)*(dots[i2].x-dots[n-i3-1].x)+(dots[i2].y-dots[n-i3-1].y)*(dots[i2].y-dots[n-i3-1].y)+(dots[i2].z-dots[n-i3-1].z)*(dots[i2].z-dots[n-i3-1].z);
dots[i2].len[n-i2-2-i3]=sqrt(dots[i2].len[n-i2-2-i3]);
}
}
for (int j=0;j<n*(n-1)/2;j++)
{int maxq=0,maxh=0;
double lmax=0.0;
for (int i4=0;i4<n-1;i4++)
{
for (int i5=0;i5<=n-2-i4;i5++)
{
if (dots[i4].len[i5]>lmax){lmax=dots[i4].len[i5];maxq=i4;maxh=i4+i5+1;}
}
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dots[maxq].x,dots[maxq].y,dots[maxq].z,dots[maxh].x,dots[maxh].y,dots[maxh].z,dots[maxq].len[maxh-1-maxq]);
dots[maxq].len[maxh-1-maxq]=0;
}
return 0;
}
| 64 |
31,997 | 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 |
31,998 | 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 |
31,999 | int main()
{
int i,j,k,l,n,m,a[10],b[10],c[10],z[50],x[50],v[50],s[50],d[50],f[50],q,w,r,t,o,u;
double y[50],jl[50],e;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&a[i],&b[i],&c[i]);
}
m=n*(n-1)/2;
k=0;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
y[k]=1.0*((a[j]-a[i])*(a[j]-a[i])+(b[j]-b[i])*(b[j]-b[i])+(c[j]-c[i])*(c[j]-c[i]));
jl[k]=sqrt(y[k]);
z[k]=a[i];
x[k]=b[i];
v[k]=c[i];
s[k]=a[j];
d[k]=b[j];
f[k]=c[j];
k++;
}
}
for(l=1;l<=m;l++)
{
for(i=0;i<m-l;i++)
{
if(jl[i]<jl[i+1])
{
e=jl[i];
jl[i]=jl[i+1];
jl[i+1]=e;
q=z[i];
z[i]=z[i+1];
z[i+1]=q;
w=x[i];
x[i]=x[i+1];
x[i+1]=w;
r=v[i];
v[i]=v[i+1];
v[i+1]=r;
t=s[i];
s[i]=s[i+1];
s[i+1]=t;
o=d[i];
d[i]=d[i+1];
d[i+1]=o;
u=f[i];
f[i]=f[i+1];
f[i+1]=u;
}
}
}
for(i=0;i<m;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",z[i],x[i],v[i],s[i],d[i],f[i],jl[i]);
}
return 0;
} | 64 |