id
int32 0
32.5k
| code
stringlengths 95
8.4k
| label
stringclasses 65
values |
---|---|---|
31,600 | struct point{
int x;
int y;
int z;
};
struct diskumi{
struct point po1;
struct point po2;
double dist;
};
int main()
{
int n;
int xa[15],ya[15],za[15];
struct diskumi dis[45];
int baka;
double cir;
int i,j,k=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&xa[i],&ya[i],&za[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
dis[k].po1.x=xa[i];
dis[k].po1.y=ya[i];
dis[k].po1.z=za[i];
dis[k].po2.x=xa[j];
dis[k].po2.y=ya[j];
dis[k].po2.z=za[j];
dis[k].dist=sqrt((xa[i]-xa[j])*(xa[i]-xa[j])+(ya[i]-ya[j])*(ya[i]-ya[j])+(za[i]-za[j])*(za[i]-za[j]));
k++;
}
}
for(i=0;i<k-1;i++)
{
for(j=0;j<k-i-1;j++)
{
if(dis[j+1].dist>dis[j].dist)
{
baka=dis[j].po1.x;
dis[j].po1.x=dis[j+1].po1.x;
dis[j+1].po1.x=baka;
baka=dis[j].po1.y;
dis[j].po1.y=dis[j+1].po1.y;
dis[j+1].po1.y=baka;
baka=dis[j].po1.z;
dis[j].po1.z=dis[j+1].po1.z;
dis[j+1].po1.z=baka;
baka=dis[j].po2.x;
dis[j].po2.x=dis[j+1].po2.x;
dis[j+1].po2.x=baka;
baka=dis[j].po2.y;
dis[j].po2.y=dis[j+1].po2.y;
dis[j+1].po2.y=baka;
baka=dis[j].po2.z;
dis[j].po2.z=dis[j+1].po2.z;
dis[j+1].po2.z=baka;
cir=dis[j].dist;
dis[j].dist=dis[j+1].dist;
dis[j+1].dist=cir;
}
}
}
k--;
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf",dis[0].po1.x,dis[0].po1.y,dis[0].po1.z,dis[0].po2.x,dis[0].po2.y,dis[0].po2.z,dis[0].dist);
for(i=1;i<=k;i++)
{
printf("\n(%d,%d,%d)-(%d,%d,%d)=%.2lf",dis[i].po1.x,dis[i].po1.y,dis[i].po1.z,dis[i].po2.x,dis[i].po2.y,dis[i].po2.z,dis[i].dist);
}
} | 64 |
31,601 | int main()
{
int n,i,t,j,m,k;
float a[10],b[10],c[10];
float d[10][10];
int e[10][10];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%f %f %f",&a[i],&b[i],&c[i]);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
d[i][j]=sqrt((a[i]-a[j])*(a[i]-a[j])+(b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]));
e[i][j]=1;
}
}
for(t=1;t<300;t++)
{
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(e[i][j]==0)
continue;
for(m=0;m<n-1;m++)
{
for(k=m+1;k<n;k++)
{
if(d[i][j]<d[m][k]&&e[m][k]!=0)
break;
}
if(k<n)
break;
}
if(m==n-1)
{
printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",a[i],b[i],c[i],a[j],b[j],c[j],d[i][j]);
e[i][j]=0;
break;
}
}
if(j<n)
break;
}
}
return 0;
}
| 64 |
31,602 | int main(){
int n,m,i,a,b,*sz,*jd,*wd;
double *d,c;
scanf("%d",&n);
m=0;
for(i=0;i<n;i++){
m+=n-1-i;
}
sz=(int*)malloc(sizeof(int)*3*n);
d=(double*)malloc(sizeof(double)*m);
jd=(int*)malloc(sizeof(int)*m);
wd=(int*)malloc(sizeof(int)*m);
for(i=0;i<3*n;i++){
scanf("%d",&sz[i]);
}
i=0;
for(a=0;a<n;a++){
for(b=a+1;b<n;b++){
d[i]=sqrt(1.0*(sz[3*a+0]-sz[3*b+0])*(sz[3*a+0]-sz[3*b+0])+(sz[3*a+1]-sz[3*b+1])*(sz[3*a+1]-sz[3*b+1])+(sz[3*a+2]-sz[3*b+2])*(sz[3*a+2]-sz[3*b+2]));
jd[i]=a;
wd[i]=b;
i++;
}
}
for(a=1;a<=m;a++){
for(b=0;b<m-a;b++){
if(d[b]<d[b+1]){
c=d[b];
d[b]=d[b+1];
d[b+1]=c;
i=jd[b];
jd[b]=jd[b+1];
jd[b+1]=i;
i=wd[b];
wd[b]=wd[b+1];
wd[b+1]=i;
}
}
}
for(i=0;i<m;i++){
a=jd[i];
b=wd[i];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sz[3*a+0],sz[3*a+1],sz[3*a+2],sz[3*b+0],sz[3*b+1],sz[3*b+2],d[i]);
}
free(sz);
free(d);
free(jd);
free(wd);
return 0;
}
| 64 |
31,603 | 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 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[n];
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);
}
double a[n * (n - 1) / 2];//??????
int k = 0;
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
int t = 0;
while (t < k + 1 && (a[t] - Distance(p[i], p[j]) > 0.00001
|| Distance(p[i], p[j]) - a[t] > 0.00001))
//?????double????????????????????????????
t++;
if (t == k + 1) {
a[k] = Distance(p[i], p[j]);
k++;
}
//Output(p[i],p[j]);
}
}//????????????????????
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;
}
}
}//??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)//a[k]==Distance(p[i],p[j])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n\n", p[i]->x, p[i]->y, p[i]->z, p[j]->x, p[j]->y,
p[j]->z, Distance(p[i], p[j]));
} else {
if (Distance(p[i], p[j]) - a[k] < 0.000001)//a[k]==Distance(p[i],p[j])
Output(p[i], p[j]);
}//float???????????????????
}
}
k++;
}
}
| 64 |
31,604 | 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 |
31,605 | 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 |
31,606 | int main()
{
typedef struct _Point
{
int x,y,z;
} Point;
typedef struct _Distance
{
int first, second;
float dist;
} Distance;
Point point[10];
int n;
scanf("%d", &n);
int i,j,total = n*(n-1)>>1;
n--;
for(i=0; i<=n; i++)
scanf("%d%d%d", &point[i].x, &point[i].y, &point[i].z);
Distance * pDistance = (Distance *)malloc(total * sizeof(Distance));
int k = 0;
for(i=0; i<n; i++)
for(j=i+1; j<=n; j++)
{
pDistance[k].first = i;
pDistance[k].second = j;
pDistance[k].dist = sqrt((float)((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=1; i<total; i++)
{
int tmp = total - i;
for(j=0; j<tmp; j++)
if(pDistance[j].dist < pDistance[j+1].dist)
{
Distance tmp = pDistance[j];
pDistance[j] = pDistance[j+1];
pDistance[j+1] = tmp;
}
}
for(i=0; i<k; i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", point[pDistance[i].first].x, point[pDistance[i].first].y,
point[pDistance[i].first].z, point[pDistance[i].second].x, point[pDistance[i].second].y,
point[pDistance[i].second].z, pDistance[i].dist);
free(pDistance);
return 0;
} | 64 |
31,607 | 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 |
31,608 |
int main()
{
struct distance
{
int num;
int x[4];
int y[4];
double d;
}a[N*(N-1)/2],t;
double dis(int x[3],int y[3]);
int p[N][3];
int n,i,j,r,k;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&p[i][j]);
}
}
for(i=0,r=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
a[r].d=dis(p[i],p[j]);
//printf("%.2lf\n",a[r].d);
for(k=0;k<3;k++)
{
a[r].x[k]=p[i][k];
a[r].y[k]=p[j][k];
}
a[r].x[3]=i;
a[r].y[3]=j;
r++;
}
}
n=r;
for(i=0;i<n-1;i++)
{
for(j=0;j<n-i-1;j++)
{
if(a[j].d<a[j+1].d)
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
else if(a[j].d==a[j+1].d)
{
if(a[j].x[3]>a[j+1].x[3])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
}
for(i=0;i<n;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=",a[i].x[0],a[i].x[1],a[i].x[2],a[i].y[0],a[i].y[1],a[i].y[2]);
printf("%.2lf\n",a[i].d);
}
return 0;
}
double dis(int x[3],int y[3])
{
double z=0;
int i;
for(i=0;i<3;i++)
{
z=z+1.0*(y[i]-x[i])*(y[i]-x[i]);
}
z=sqrt(z);
return z;
} | 64 |
31,609 | int main()
{
int n,i,j,k=0,x[10],y[10],z[10],a[90],b[90];//n:??,i,j,k=0,?????x[10],y[10],z[10]????x?y?z??,a[90],b[90]?????????
double l[90],p;//l[90]:???p:?????????
cin>>n;
for(i=0;i<n;i++)
cin>>x[i]>>y[i]>>z[i];
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
l[k]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
a[k]=i;
b[k]=j;
k++;
}
for(i=1;i<k;i++)
for(j=0;j<k-i;j++)
{
if(l[j]<l[j+1])
{
p=l[j];
l[j]=l[j+1];
l[j+1]=p;
p=a[j];
a[j]=a[j+1];
a[j+1]=p;
p=b[j];
b[j]=b[j+1];
b[j+1]=p;
}
}
for(i=0;i<k;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[a[i]],y[a[i]],z[a[i]],x[b[i]],y[b[i]],z[b[i]],l[i]);
return 0;
} | 64 |
31,610 | int main(){
int i,j,k,m,n,a,b;
int sz[200] [4];
scanf("%d",&n);
double r[200][200],o[100000],e;
for(i=0;i<n;i++){
scanf("%d %d %d",&sz[i] [1],&sz[i] [2],&sz[i] [3]);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
r[i][j]=sqrt((double)(((sz[i][1])-(sz[j][1]))*((sz[i][1])-(sz[j][1]))+((sz[i][2])-(sz[j][2]))*((sz[i][2])-(sz[j][2]))+((sz[i][3])-(sz[j][3]))*((sz[i] [3])-(sz[j][3]))));
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
o[(i)*n+j]=r[i][j];
}
}
for(i=1;i<=n*n;i++){
for(j=1;j<n*n;j++){
if(o[j]<o[j+1]){
e=o[j];
o[j]=o[j+1];
o[j+1]=e;
}
}
}
//for(i=1;i<=n*n;i++)cout<<o[i];
for(i=0;i<n*n;i++){
if(o[i]==o[i-1])
continue;
for(j=0;j<n;j++){
for(b=j+1;b<n;b++){
if(o[i+1]==r[j][b]){printf("(%d,%d,%d)",sz[j][1],sz[j][2],sz[j][3]);printf("%c",'-');
printf("(%d,%d,%d)",sz[b][1],sz[b][2],sz[b][3]);printf("%c",'=');
printf("%.2lf",r[b][j]);cout<<endl;
}
}
}
}
return 0;
}
| 64 |
31,611 | //**********************************************************
//* ?????1.cpp *
//* ??????1200012906 *
//* ???2012?12?10? *
//* ????????? *
//**********************************************************
struct
{
int id;
int x1;
int y1;
int z1;
int x2;
int y2;
int z2;
double distance;
}date[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++)
{
date[k].id = k;
date[k].x1 = x[i];
date[k].y1 = y[i];
date[k].z1 = z[i];
date[k].x2 = x[j];
date[k].y2 = y[j];
date[k].z2 = z[j];
date[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 = k - 2; i >= 0; i--)
for(j = k - 1; j >= i + 1; j--)
{
if (date[i].distance < date[j].distance || date[i].distance == date[j].distance && date[j].id < date[i].id)
{ //???????????????
t = date[i];
date[i] = date[j];
date[j] = t;
}
}
for(i = 0; i < k; i++)
{
cout << "(" << date[i].x1 << "," << date[i].y1 << "," << date[i].z1 << ")-(";
cout << date[i].x2 << "," << date[i].y2 << "," << date[i].z2 << ")=";
cout << fixed << setprecision(2) << sqrt(date[i].distance) << endl;
}
return 0;
} | 64 |
31,612 | int main(){
int a[10][3],dian[50][2],n,i,j,k=0,m;
double d[50],temp;
cin >> n;
for(i=0;i<n;i++){
cin >> 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((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]));
dian[k][0]=i;
dian[k][1]=j;
k++;}
}
for(i=0;i<k-1;i++){
for(j=0;j<k-i-1;j++){
if(d[j]<d[j+1]){
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
m=dian[j][0],dian[j][0]=dian[j+1][0],dian[j+1][0]=m;
m=dian[j][1],dian[j][1]=dian[j+1][1],dian[j+1][1]=m;
}
}
}
for(i=0;i<k;i++){
cout <<"("<<a[dian[i][0]][0]<<","<<a[dian[i][0]][1]<<","<<a[dian[i][0]][2]<<")"<<"-"<<"("<<a[dian[i][1]][0]<<","<<a[dian[i][1]][1]<<","<<a[dian[i][1]][2]<<")"<<"="<<fixed<<setprecision(2)<<d[i]<<endl;
}
return 0;
}
| 64 |
31,613 | 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 |
31,614 | /*
* juli.cpp
*??: ?????????
* Created on: 2012-11-9
* Author: ??
*/
int main() {
int n, i, j, k = 0, x[10], y[10], z[10], start[45], end[45];//??n???????????
double dis[45];//????
cin >> n;
for (i = 0; i < n; i++)
cin >> x[i] >> y[i] >> z[i];//??
for (i = 0; i < n - 1; i++)
for (j = i + 1; j < n; j++) {
start[k] = i;
end[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++;//???????????????????????
}
for (i = 0; i < k - 1; i++)
for (j = 0; j < k - i - 1; j++) {
if (dis[j] < dis[j + 1]) {
swap(dis[j], dis[j + 1]);
swap(start[j], start[j + 1]);
swap(end[j], end[j + 1]);//????
}
}
for (i = 0; i < k; i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", x[start[i]], y[start[i]],
z[start[i]], x[end[i]], y[end[i]], z[end[i]], dis[i]);//?????
return 0;
}
| 64 |
31,615 | int main()
{
int syz[10][3];
int i,j,n,d,y,k,r=0;
double result,sy[45];
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&syz[i][j]);
}
}
for(i=0;i<n-1;i++)
{
for(k=i+1;k<n;k++)
{
result=sqrt(1.0*(syz[k][0]-syz[i][0])*(syz[k][0]-syz[i][0])+1.0*(syz[k][1]-syz[i][1])*(syz[k][1]-syz[i][1])+1.0*(syz[k][2]-syz[i][2])*(syz[k][2]-syz[i][2]));
sy[r]=result;
r++;
}
}
/*
?????sy???double???????e????double??
int e;
*/
double e;
for(d=1;d<=n*(n-1)/2;d++)
{
for(y=0;y<n*(n-1)/2-d;y++)
{
if(sy[y]<=sy[y+1])
{
e=sy[y];
sy[y]=sy[y+1];
sy[y+1]=e;
}
}
}
/*
for(i=1,k=1;j<n*(n-1)/2;i++)
??????????i??????
*/
for(i=1,k=1;i<n*(n-1)/2;i++)
{
for(j=0;j<k;j++)
{
/*
????????==?????????????
if(sy[i]==sy[j])
*/
if(fabs(sy[i]-sy[j]) < 0.000001)
{
break;
}
}
if(j==k)
{
sy[k]=sy[i];
k++;
}
}
/*
???k????????????????
for(y=0;y<k;y++)
*/
int kk = k;
for(y=0;y<kk;y++)
{
for(i=0;i<n-1;i++)
{
for(k=i+1;k<n;k++)
{
/*
????????????????????
if(sqrt(1.0*(syz[k][0]-syz[i][0])*(syz[k][0]-syz[i][0])+1.0*(syz[k][1]-syz[i][1])*(syz[k][1]-syz[i][1])+1.0*(syz[k][2]-syz[i][2])*(syz[k][2]-syz[i][2]))==sy[y])
*/
if(fabs(sqrt(1.0*(syz[k][0]-syz[i][0])*(syz[k][0]-syz[i][0])+1.0*(syz[k][1]-syz[i][1])*(syz[k][1]-syz[i][1])+1.0*(syz[k][2]-syz[i][2])*(syz[k][2]-syz[i][2]))-sy[y])<0.00001)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",syz[i][0],syz[i][1],syz[i][2],syz[k][0],syz[k][1],syz[k][2],sy[y]);
}
}
}
}
return 0;
}
| 64 |
31,616 | double distance(double q,double w,double e,double r,double t,double y)
{
double u;
u=sqrt((q-r)*(q-r)+(w-t)*(w-t)+(e-y)*(e-y));
return u;
}
int main(){
int a,b,e,f,g,h,n,i;
double d[10][10],c;
struct z
{
double j;
double k;
double l;
}
s[10];
scanf("%d\n",&n);
for(i=0;i<n-1;i++){
scanf("%lf%lf%lf ",&s[i].j,&s[i].k,&s[i].l);
}
scanf("%lf%lf%lf",&s[n-1].j,&s[n-1].k,&s[n-1].l);
for(a=0;a<n-1;a++){
for(b=a+1;b<n;b++){
d[a][b]=distance(s[a].j,s[a].k,s[a].l,s[b].j,s[b].k,s[b].l);
}
}
for(e=n*(n-1)/2;e>0;e--){
for(a=0,c=0;a<n-1;a++){
for(b=a+1;b<n;b++){
if(c<d[a][b]){
c=d[a][b];
f=a;
g=b;
}
}
}
d[f][g]=0;
printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",s[f].j,s[f].k,s[f].l,s[g].j,s[g].k,s[g].l,c);
}
return 0;
}
| 64 |
31,617 |
int main()
{
int p[10][3],d2[10][10];
float d[10][10];
int i,j,k=0,n,N;
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<3;j++)
scanf("%d",&p[i][j]);
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
d2[i][j]=(p[i][0]-p[j][0])*(p[i][0]-p[j][0])+(p[i][1]-p[j][1])*(p[i][1]-p[j][1])+(p[i][2]-p[j][2])*(p[i][2]-p[j][2]);
d[i][j]=sqrt((float)d2[i][j]);
}
struct {float d;int p1;int p2;}A[46];
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
A[k].d=d[i][j];
A[k].p1=i;
A[k].p2=j;
k++;
}
N=k;
for(k=0;k<N;k++)
for(j=0;j<N-1-k;j++)
if(A[j].d<A[j+1].d)
{
A[45]=A[j];
A[j]=A[j+1];
A[j+1]=A[45];
}
for(k=0;k<N;k++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",p[A[k].p1][0],p[A[k].p1][1],p[A[k].p1][2],p[A[k].p2][0],p[A[k].p2][1],p[A[k].p2][2],A[k].d);
return 0;
}
| 64 |
31,618 | /*
* 1.cpp
*
* Created on: 2012-10-8
* Author: Lixurong
*/
int runnian( int a );
int main()
{
int n, k;//????
cin >> n;//????
k = n*(n-1)/2;//????
double a[n][3];//????
double b[k][3];//????
for( int i=0; i<n; i++ )//????
{
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
int p=0;
for( int i=0; i<n-1; i++ )//??????
{
for( int j=i+1; j<n; j++ )
{
b[p][1]=i;
b[p][2]=j;
b[p][0]=sqrt(pow((a[i][0]-a[j][0]),2)+pow((a[i][1]-a[j][1]),2)+pow((a[i][2]-a[j][2]),2));
p++;
}
}
for( int i=0; i<k-1; i++ )//????
{
for( int j=0;j<k-1; j++ )
{
if( b[j][0]<b[j+1][0] )
{
double h=b[j][0];
b[j][0]=b[j+1][0];
b[j+1][0]=h;
int s=(int)b[j][1];
b[j][1]=b[j+1][1];
b[j+1][1]=s;
int e=(int)b[j][2];
b[j][2]=b[j+1][2];
b[j+1][2]=e;
}
}
}
for( int i=0; i<k; i++ )//????
{
cout << "(" << fixed << setprecision(0) << a[(int)b[i][1]][0] << "," << a[(int)b[i][1]][1] << "," << a[(int)b[i][1]][2]
<< ")-(" << a[(int)b[i][2]][0] << "," << a[(int)b[i][2]][1] << "," << a[(int)b[i][2]][2]
<< ")=" << fixed << setprecision(2) << b[i][0];
if( i!=k-1 )
cout << endl;
}
return 0;
}
| 64 |
31,619 | 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 |
31,620 | float f(int a,int b,int c,int d,int e,int f);
int main()
{
int x[11],y[11],z[11],i,j,n,num=0;
scanf("%d",&n);
//scanf("%d %d %d",&x[0],&y[0],&z[0]);
for(i=0;i<n;i++)
scanf("%d %d %d",&x[i],&y[i],&z[i]);
struct POINT
{
int point1x;
int point1y;
int point1z;
int point2x;
int point2y;
int point2z;
int mark;
float l;
};
struct POINT temp;
struct POINT d[55];
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
d[num].mark=num;
d[num].point1x=x[i];d[num].point1y=y[i];d[num].point1z=z[i];
d[num].point2x=x[j];d[num].point2y=y[j];d[num].point2z=z[j];
d[num].l=f(x[i],y[i],z[i],x[j],y[j],z[j]);
num=num+1; //printf("%.2f\n",d[num].l);printf("%d %d %d %d %d %d\n",x[i],y[i],z[i],x[j],y[j],z[j]);
}
} //for(i=num-1;i>=0;i--)printf("%.2f\n",d[i].l);//printf("%d\n",num);
for(i=1;i<num;i++)
{
for(j=0;j<num-i;j++)
{
if(d[j].l>d[j+1].l)
{
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
}
}
}
for(i=1;i<num;i++)
{
for(j=0;j<num-i;j++)
{
if(d[j].l==d[j+1].l&&d[j].mark<d[j+1].mark)
{
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
}
}
} //printf("%.2f\n",d[3].l);
for(i=num-1;i>=0;i--)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",d[i].point1x,d[i].point1y,d[i].point1z,d[i].point2x,d[i].point2y,d[i].point2z,d[i].l);
return 0;
}
float f(int a,int b,int c,int d,int e,int f)
{
float length;
length=sqrt((a-d)*(a-d)+(b-e)*(b-e)+(c-f)*(c-f));
return(length);
} | 64 |
31,621 | unsigned int com[45][2];
float dis[45];
void swap(int i,int j)
{
unsigned int t_1[2];
float t_2;
t_2=dis[i];
dis[i]=dis[j];
dis[j]=t_2;
t_1[0]=com[i][0];
com[i][0]=com[j][0];
com[j][0]=t_1[0];
t_1[1]=com[i][1];
com[i][1]=com[j][1];
com[j][1]=t_1[1];
}
int main(void)
{
int i,j,n,s=0,coord[10][3];
for(i=0;i<45;i++)
dis[i]=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d ",&coord[i][0],&coord[i][1],&coord[i][2]);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
com[s][0]=i;
com[s][1]=j;
dis[s]=sqrt(pow(coord[i][0]-coord[j][0],2)+pow(coord[i][1]-coord[j][1],2)+pow(coord[i][2]-coord[j][2],2));
s++;
}
for(i=s;i>0;i--)
for(j=0;j<i-1;j++)
if(dis[j]<dis[j+1])
swap(j,j+1);
for(i=0;i<s;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",coord[com[i][0]][0],coord[com[i][0]][1],coord[com[i][0]][2],coord[com[i][1]][0],coord[com[i][1]][1],coord[com[i][1]][2],dis[i]);
fclose(stdin);
return 0;
} | 64 |
31,622 | int n,x,y,z;
int p;
struct point
{
int x,y,z;
}
points[10];
struct print
{
double l;
struct point p1,p2;
}
prints[45];
void scan();
void count();
void sort();
void print();
int main(){
scan();
count();
sort();
print();
return 0;
}
void scan(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d%d",&x,&y,&z);
points[i].x=x;
points[i].y=y;
points[i].z=z;
}
}
void count(){
int x1,y1,z1,x2,y2,z2;
p=0;
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
x1=points[i].x;
y1=points[i].y;
z1=points[i].z;
x2=points[j].x;
y2=points[j].y;
z2=points[j].z;
prints[p].l=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
prints[p].p1=points[i];
prints[p].p2=points[j];
p++;
}
}
}
void sort(){
struct print temp;
for(int k=1;k<=p;k++){
for(int i=0;i<p-k;i++){
if(prints[i].l<prints[i+1].l){
temp=prints[i+1];
prints[i+1]=prints[i];
prints[i]=temp;
}
}
}
}
void print(){
int x1,y1,z1,x2,y2,z2;
double l;
for(int i=0;i<p;i++){
x1=prints[i].p1.x;
y1=prints[i].p1.y;
z1=prints[i].p1.z;
x2=prints[i].p2.x;
y2=prints[i].p2.y;
z2=prints[i].p2.z;
l=prints[i].l;
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x1,y1,z1,x2,y2,z2,l);
}
}
| 64 |
31,623 | 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 |
31,624 | int main(){
int i,x,n,g,l,p,a,b,c;
double e;
double dst[45];
int xz[10];int yz[10];int zz[10];
int dx[45];int dy[45];int dz[45];
int sx[45];int sy[45];int sz[45];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d ",&(xz[i]),&(yz[i]),&(zz[i]));
}
g=0;
for(i=0;i<n-1;i++){
for(x=i+1;x<n;x++){
a=((xz[i])-(xz[x]))*((xz[i])-(xz[x]));
b=((yz[i])-(yz[x]))*((yz[i])-(yz[x]));
c=((zz[i])-(zz[x]))*((zz[i])-(zz[x]));
dst[g]=pow((double)(a+b+c),0.5);
dx[g]=xz[i];dy[g]=yz[i];dz[g]=zz[i];
sx[g]=xz[x];sy[g]=yz[x];sz[g]=zz[x];
g=g+1;
}
}
for(i=0;i<g;i++){
for(x=0;x<g-i-1;x++){
if(dst[x]<dst[x+1]){
e=dst[x+1];
dst[x+1]=dst[x];
dst[x]=e;
l=dx[x+1];
dx[x+1]=dx[x];
dx[x]=l;
l=dy[x+1];
dy[x+1]=dy[x];
dy[x]=l;
l=dz[x+1];
dz[x+1]=dz[x];
dz[x]=l;
l=sx[x+1];
sx[x+1]=sx[x];
sx[x]=l;
l=sy[x+1];
sy[x+1]=sy[x];
sy[x]=l;
l=sz[x+1];
sz[x+1]=sz[x];
sz[x]=l;
}
}
}
for(i=0;i<g;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n\n",dx[i],dy[i],dz[i],sx[i],sy[i],sz[i],dst[i]);
}
return 0;
} | 64 |
31,625 | int point[MAX][3];
double d;
struct {
int x1,x2,y1,y2,z1,z2;
double d;
}dis[DIS],mid;
int n,m=0,i,j;
int main()
{
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++)
{
dis[m].x1=point[i][0];
dis[m].y1=point[i][1];
dis[m].z1=point[i][2];
dis[m].x2=point[j][0];
dis[m].y2=point[j][1];
dis[m].z2=point[j][2];
dis[m].d=sqrt(pow((dis[m].x1-dis[m].x2),2)+pow((dis[m].y1-dis[m].y2),2)+pow((dis[m].z1-dis[m].z2),2));
m++;
}
}
for(i=0;i<m;i++)
{
for(j=0;j<m-1;j++)
{
if(dis[j].d<dis[j+1].d)
{
mid=dis[j];
dis[j]=dis[j+1];
dis[j+1]=mid;
}
}
}
for(i=0;i<m;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dis[i].x1,dis[i].y1,dis[i].z1,dis[i].x2,dis[i].y2,dis[i].z2,dis[i].d);
}
return 0;
}
| 64 |
31,626 |
int main(){
int n=0,x[11],y[11],z[11],a[51][3];
double d[50];
scanf("%d\n",&n);
for(int i=1;i<=n;i++)
scanf("%d %d %d ",&x[i],&y[i],&z[i]);
int cnt=0;
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++){
int c=++cnt;
d[c]=sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j])+sqr(z[i]-z[j]));
a[c][1]=i;
a[c][2]=j;
}
for(int i=1;i<=cnt;i++)
for(int j=cnt;j>i;j--)
if(d[j-1]<d[j]){
double t1;
int t2,t3;
t1=d[j-1];
d[j-1]=d[j];
d[j]=t1;
t2=a[j-1][1];
t3=a[j-1][2];
a[j-1][1]=a[j][1];
a[j-1][2]=a[j][2];
a[j][1]=t2;
a[j][2]=t3;
}
for(int i=1;i<=cnt;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",
x[a[i][1]],y[a[i][1]],z[a[i][1]],x[a[i][2]],y[a[i][2]],z[a[i][2]],d[i]);
return 0;
}
| 64 |
31,627 | int main()
{
int x[10],X1[45],X2[45],xjl[45];
int y[10],Y1[45],Y2[45],yjl[45];
int z[10],Z1[45],Z2[45],zjl[45];
int he[45];
double juli[45];
int n, i;
scanf("%d", &n);
for(i=0;i<n;i++){
scanf("%d%d%d",&(x[i]),&(y[i]),&(z[i]));
}
int m,f=0;
for(m=0 ; m < n-1 ; m++){
for(i = m+1; i < n ; i++){
xjl[f]=(x[m]-x[i])*(x[m]-x[i]);
yjl[f]=(y[m]-y[i])*(y[m]-y[i]);
zjl[f]=(z[m]-z[i])*(z[m]-z[i]);
X1[f]=x[m];
X2[f]=x[i];
Y1[f]=y[m];
Y2[f]=y[i];
Z1[f]=z[m];
Z2[f]=z[i];
f++;
}
}
for(m=0 ; m < f ; m++){
he[m]=xjl[m]+yjl[m]+zjl[m];
}
for(m=0 ; m < f ; m++){
juli[m]=sqrt(he[m]);
}
double e;
int h;
for(m=1 ; m < f ; m++){
for(i = 0; i < f - m; i++){
if(juli[i] < juli[i+1]){
e = juli[i+1];
juli[i+1] = juli[i];
juli[i] = e;
h = X1[i+1];
X1[i+1] = X1[i];
X1[i] = h;
h = X2[i+1];
X2[i+1] = X2[i];
X2[i] = h;
h = Y1[i+1];
Y1[i+1] = Y1[i];
Y1[i] = h;
h = Y2[i+1];
Y2[i+1] = Y2[i];
Y2[i] = h;
h = Z1[i+1];
Z1[i+1] = Z1[i];
Z1[i] = h;
h = Z2[i+1];
Z2[i+1] = Z2[i];
Z2[i] = h;
}
}
}
for(m=0;m<f;m++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",X1[m],Y1[m],Z1[m],X2[m],Y2[m],Z2[m],juli[m]);
}
return 0;
}
| 64 |
31,628 |
int main() {
int n, j, i, k = 0, m;
float p = 0, a[100] = { 0 };
int x[10], y[10], z[10];
float s[10][10] = { 0 };
cin >> n;
for (i = 0; i < n; i++)
cin >> x[i] >> y[i] >> z[i];
for (i = 0; i < n; i++) {//????
for (j = i + 1; j < n; j++) {
a[k++] = s[i][j] = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j])
* (y[i] - y[j]) + (z[i] - z[j]) * (z[i] - z[j]);
}
}
for (i = 0; i < k - 1; i++) {//??
for (j = 0; j < k - 1 - i; j++) {
if (a[j] < a[j + 1]) {
p = a[j];
a[j] = a[j + 1];
a[j + 1] = p;
}
}
}
for (j = 0; j < n; j++) {
for (i = 0; i < n; i++) {
if (a[0] == s[i][j])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", x[i], y[i], z[i], x[j],
y[j], z[j], sqrt(a[0]));
}
}
for (m = 1; m < k; m++) {
for (j = 0; j < n; j++) {
for (i = 0; i < n; i++) {
if (a[m] == s[i][j] && a[m] != a[m - 1])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n", x[i], y[i], z[i],
x[j], y[j], z[j], sqrt(a[m]));
}
}
}
return 0;
} | 64 |
31,629 | int main(){
int n,i,j,k,t,m,pair;
double e;
double sz[10][3],num[45][7];
scanf("%d",&n);
pair=n*(n-1)/2;
for(i=0;i<n;i++){
for(j=0;j<3;j++){
scanf("%lf",&sz[i][j]);
}
}
m=0;
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
for(k=0;k<3;k++){
num[m][k]=sz[i][k];
}
for(t=3;t<6;t++){
num[m][t]=sz[j][t-3];
}
num[m][6]=sqrt((num[m][0]-num[m][3])*(num[m][0]-num[m][3])+(num[m][1]-num[m][4])*(num[m][1]-num[m][4])+(num[m][2]-num[m][5])*(num[m][2]-num[m][5]));
m++;
}
}
for(k=1;k<=pair;k++){
for(i=0;i<pair-k;i++){
if(num[i][6]<num[i+1][6]){
for(t=0;t<7;t++){
e=num[i+1][t];
num[i+1][t]=num[i][t];
num[i][t]=e;
}
}
}
}
for(t=0;t<pair;t++){
printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",(num[t][0]),(num[t][1]),(num[t][2]),(num[t][3]),(num[t][4]),(num[t][5]),(num[t][6]));
}
return 0;
}
| 64 |
31,630 | /*
* 3.cpp
*
* Created on: 2012-11-3
* Author: AK
*/
int main(){
double a[50][3]; //???????????????????
double distance;
int x[10],y[10],z[10]; //?????????
int n,x1,y1,z1,i,j,k=0; //?????????
cin>>n;
for(i=0;i<n;i++){ //????????
cin>>x1>>y1>>z1;
x[i]=x1;y[i]=y1;z[i]=z1;
}
for(i=0;i<=n-2;i++) //???????????????????????????
for(j=i+1;j<=n-1;j++)
{
a[k][0]=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][1]=i;a[k][2]=j;k++;
}
for(i=1;i<=k-1;i++) //??????????????????????????????????????
for(j=k-1;j>=i;j--)
{
if(a[j][0]>a[j-1][0])
{
distance=a[j-1][0];a[j-1][0]=a[j][0];a[j][0]=distance;
distance=a[j-1][1];a[j-1][1]=a[j][1];a[j][1]=distance;
distance=a[j-1][2];a[j-1][2]=a[j][2];a[j][2]=distance;
}
}
for(i=0;i<=k-1;i++) //???? ????????????printf????
{
cout<<'('<<x[(int)(a[i][1])]<<','<<y[(int)(a[i][1])]<<','<<z[(int)(a[i][1])]<<")-(";
cout<<x[(int)(a[i][2])]<<','<<y[(int)(a[i][2])]<<','<<z[(int)(a[i][2])]<<")=";
cout<<fixed<<setprecision(2)<<a[i][0]<<endl;
}
return 0;
} | 64 |
31,631 | 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 |
31,632 |
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 |
31,633 | int main()
{
int n,i,j,i1,j1,k;
double x[11],y[11],z[11],r[10][11];//?i????j??????r[i][j],?i??????(x[i],y[i],z[i])
cin>>n;//?n??
for(i=1;i<=n;i++)
cin>>x[i]>>y[i]>>z[i];//????
for(i=1;i<n;i++){
for(j=1;j<=n;j++)
r[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
}//?????????
double max=0;//?max?????????
for(k=1;k<=100;k++){
for(i=1;i<n;i++){
for(j=i;j<=n;j++){
if(r[i][j]>max){
max=r[i][j];
i1=i;j1=j;//????????????
}
}
}
if(max!=0){
cout<<fixed<<setprecision(0)<<"("<<x[i1]<<","<<y[i1]<<","<<z[i1]<<")-("<<x[j1]<<","<<y[j1]<<","<<z[j1]<<")=";
cout<<fixed<<setprecision(2)<<r[i1][j1]<<endl;
r[i1][j1]=0;//???????
max=0;}
}
return 0;
} | 64 |
31,634 | void main()
{
int i,j,k,b,c,n;
double s[100][100],max,a[100][3];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%lf %lf %lf",&a[i][0],&a[i][1],&a[i][2]);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
s[i][j]=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])));
for(k=0;k<(n*(n-1)/2);k++)
{
max=0;
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
if(s[i][j]>max)
{
max=s[i][j];
b=i;
c=j;
}
}
printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",a[b][0],a[b][1],a[b][2],a[c][0],a[c][1],a[c][2],max);
s[b][c]=0;
}
} | 64 |
31,635 | struct dis
{
int from[4];
int to[4];
double d;
}dis[6000]; //???????
int main()
{
int n,p[11][4],i,j,t=0;
cin>>n;
for (i=1;i<=n;i++)
for (j=1;j<=3;j++)
cin>>p[i][j]; //??????????????
for (i=1;i<=n-1;i++)
for (j=i+1;j<=n;j++)
{
t++;
dis[t].from[1]=p[i][1];
dis[t].from[2]=p[i][2];
dis[t].from[3]=p[i][3];
dis[t].to[1]=p[j][1];
dis[t].to[2]=p[j][2];
dis[t].to[3]=p[j][3]; //??????????
dis[t].d=sqrt(pow(p[i][1]-p[j][1],2.0)+pow(p[i][2]-p[j][2],2.0)+pow(p[i][3]-p[j][3],2.0));//??????????????????
}
for (i=1;i<=t-1;i++)
for (j=1;j<=t-i;j++)
{
if (dis[j].d<dis[j+1].d)
{
dis[0]=dis[j];
dis[j]=dis[j+1];
dis[j+1]=dis[0];
} //????????
}
for (i=1;i<=t;i++)
{
cout<<"("<<dis[i].from[1]<<","<<dis[i].from[2]<<","<<dis[i].from[3]<<")"<<"-";
cout<<"("<<dis[i].to[1]<<","<<dis[i].to[2]<<","<<dis[i].to[3]<<")"<<"=";
cout<<fixed<<setprecision(2)<<dis[i].d<<endl; //?????????
}
return 0;
}
| 64 |
31,636 | //********************************************************
//* ???:1.cpp *
//* ?????? 1200012948 *
//* ????: 2012 12 09 *
//* ????:???? *
//********************************************************
struct shuju //????????????????
{
int xx;
int yy;
double dis;
} sj[100], temp;
struct distance //????????
{
int x;
int y;
int z;
}point[10];
int main()
{
int n, i, j, k = 0;
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> point[i].x >> point[i].y >> point[i].z;
}
for (i = 1; i < n; i++)
for(j = i + 1; j <= n; j++)
{
k++;
double m = (point[i].x - point[j].x) * (point[i].x - point[j].x)
+ (point[i].y - point[j].y) * (point[i].y - point[j].y)
+ (point[i].z - point[j].z) * (point[i].z - point[j].z);
sj[k].dis = sqrt(m);
sj[k].xx = i;
sj[k].yy = j;
}
for (i = 1; i < n * (n - 1) / 2; i++) //??
for (j = 1; j <= n * (n - 1) / 2 - i; j++)
{
if (sj[j].dis < sj[j + 1].dis)
{
temp =sj[j];
sj[j] = sj[j + 1];
sj[j + 1] = temp;
}
}
for (i = 1; i <= n * (n - 1) / 2; i++)
{
cout << "(" << point[sj[i].xx].x << "," << point[sj[i].xx].y << "," << point[sj[i].xx].z << ")"
<< "-" << "(" << point[sj[i].yy].x << "," << point[sj[i].yy].y << "," << point[sj[i].yy].z << ")"
<< "=" << fixed << setprecision(2) << sj[i].dis << endl;
}
return 0;
}
| 64 |
31,637 | 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 |
31,638 | int main()
{
struct position
{int x1;
int x2;
int x3;
}pos[10];
struct distance
{int x;
int y;
float distan;
}dis[60],temp;//x??????y??????distan???
int n,i,j,k;
cin>>n;
for(i=0;i<n;i++)
{cin>>pos[i].x1;
cin>>pos[i].x2;
cin>>pos[i].x3;
}//????
k=0;
for(i=0;i<n;i++)
{for(j=i+1;j<n;j++)
{dis[k].x=i;
dis[k].y=j;
dis[k].distan=sqrt((pos[i].x1-pos[j].x1)*(pos[i].x1-pos[j].x1)+(pos[i].x2-pos[j].x2)*(pos[i].x2-pos[j].x2)+(pos[i].x3-pos[j].x3)*(pos[i].x3-pos[j].x3));
k++;}//????????????x,y,?????
}
for(i=0;i<k;i++)
{for(j=0;j<k-1-i;j++)
{if(dis[j].distan<dis[j+1].distan)
{temp=dis[j];
dis[j]=dis[j+1];
dis[j+1]=temp;
}//??????????????
}
}
for(i=0;i<k;i++)
cout<<"("<<pos[dis[i].x].x1<<","<<pos[dis[i].x].x2<<","<<pos[dis[i].x].x3<<")-("<<pos[dis[i].y].x1<<","<<pos[dis[i].y].x2<<","<<pos[dis[i].y].x3<<")="<<fixed<<setprecision(2)<<dis[i].distan<<endl;//?????
return 0;
} | 64 |
31,639 | int main()
{
int n,i,j,k=0,d,e,x[100],y[100],z[100];
double m,a[100][100]={-1},b[500]={-1},c[500];
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++){
a[i][j]=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]));
b[k]=a[i][j];
k++;
}
}
for(i=0;i<k-1;i++){
for(j=0;j<k-i-1;j++){
if(b[j]<b[j+1]){
m=b[j];
b[j]=b[j+1];
b[j+1]=m;
}
}
}
e=1;
for(i=0;i<k-1;i++){
if(b[i]==b[i+e]){
for(e=1;1;e++){
if(b[i]==b[i+e])
b[i+e]=-1;
else
break;
}
}
}
j=0;
for(i=0;i<k;i++){
if(b[i]!=-1){
c[j]=b[i];
j++;
}
}
for(i=0;i<j;i++){
for(k=0;k<n-1;k++){
for(d=k+1;d<n;d++){
if(a[k][d]==c[i])
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[k],y[k],z[k],x[d],y[d],z[d],c[i]);
}
}
}
return 0;
} | 64 |
31,640 | int main()
{
int spot[11][3],i,j,n,count=0,x,y,z;
float dis[4951][3],k;
cin >>n;
for (i=1;i<=n;i++)
for (j=0;j<3;j++)
cin >>spot[i][j];//????
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
count++;
x=spot[i][0]-spot[j][0];
y=spot[i][1]-spot[j][1];
z=spot[i][2]-spot[j][2];
dis[count][0]=sqrt(x*x+y*y+z*z);
dis[count][1]=i;
dis[count][2]=j;
}//????????
for (i=1;i<count;i++)
for (j=1;j<=count-i;j++)
if (dis[j][0]<dis[j+1][0])
{
k=dis[j][0];
dis[j][0]=dis[j+1][0];
dis[j+1][0]=k;
k=dis[j][1];
dis[j][1]=dis[j+1][1];
dis[j+1][1]=k;
k=dis[j][2];
dis[j][2]=dis[j+1][2];
dis[j+1][2]=k;
}//??
for (i=1;i<=count;i++)
{
cout <<"(" <<spot[(int)dis[i][1]][0] <<"," <<spot[(int)dis[i][1]][1] <<"," <<spot[(int)dis[i][1]][2] <<")";
cout <<"-";
cout <<"(" <<spot[(int)dis[i][2]][0] <<"," <<spot[(int)dis[i][2]][1] <<"," <<spot[(int)dis[i][2]][2] <<")";
cout <<"=";
printf("%.2f",dis[i][0]);
cout <<endl;
}
return 0;
}
| 64 |
31,641 | 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 |
31,642 | 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 |
31,643 | main()
{
int a,b,c,n,m,l,p,q;
double k;
int x[10][3];
double y[10][10];
double z[10][10];
scanf("%d",&n);
for(a=0;a<=9;a++)
{
for(b=0;b<=9;b++)
y[a][b]=-1;
}
for(a=0;a<=n-1;a++)
{
for(b=0;b<=2;b++)
scanf("%d",&x[a][b]);
}
for(a=0;a<=n-1;a++)
{
for(b=a+1;b<=n-1;b++)
y[a][b]=sqrt((x[a][0]-x[b][0])*(x[a][0]-x[b][0])+(x[a][1]-x[b][1])*(x[a][1]-x[b][1])+(x[a][2]-x[b][2])*(x[a][2]-x[b][2]));
}
for(a=0;a<=9;a++)
{
for(b=0;b<=9;b++)
z[a][b]=y[a][b];
}
for(a=1;a<=(((n*n)/2)-(n/2));a++)
{
k=-1;
m=-1;
l=-1;
for(b=0;b<=n-1;b++)
{
for(c=0;c<=n-1;c++)
{
if(y[b][c]>k)
{
m=b;
l=c;
k=y[b][c];
}
else;
}
}
y[m][l]=-1;
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[m][0],x[m][1],x[m][2],x[l][0],x[l][1],x[l][2],z[m][l]);
}
} | 64 |
31,644 | 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 |
31,645 | int main(){
int n,i,j,k,m,q;
j=0;
scanf("%d",&n);
int a[10],b[10],c[10],f[50],g[50],h[50],l[50],o[50],p[50];
double d[50];
double e;
for(i=0;i<n;i++){
scanf("%d %d %d",&a[i],&b[i],&c[i]);
}
for(i=0;i<n;i++){
for(m=i+1;m<n;m++){
e=(a[i]-a[m])*(a[i]-a[m])+
(b[i]-b[m])*(b[i]-b[m])+
(c[i]-c [m])*(c[i]-c[m]);
d[j]=sqrt(e);
f[j]=a[i];
g[j]=b[i];
h[j]=c[i];
l[j]=a[m];
o[j]=b[m];
p[j]=c[m];
j=j+1;
}
}
for(k = 1 ; k <= j ; k++){
for(i = 0; i < j- k; i++){
if(d[i] < d[i+1]){
e = d[i+1];
d[i+1] = d[i];
d[i] = e;
q= f[i+1];
f[i+1] = f[i];
f[i] = q;
q= g[i+1];
g[i+1] = g[i];
g[i] = q;
q= h[i+1];
h[i+1] = h[i];
h[i] = q;
q= l[i+1];
l[i+1] = l[i];
l[i] = q;
q= o[i+1];
o[i+1] = o[i];
o[i] = q;
q= p[i+1];
p[i+1] =p[i];
p[i] = q;
}
}
}
for(i=0;i<j;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",f[i],g[i],h[i],l[i], o[i],p[i],d[i]);
}
return 0;
}
| 64 |
31,646 | //*******************************
//*??????? **
//*?????? 1300012965 **
//*???20131211 **
//*******************************
struct zb
{
int x;
int y;
int z;
}a[11];//??????
int main()
{
double l[100] = {0.0};
int i, j, k, n, co = 0, q[100] = {0}, temp, x1, y1, co1 = 0;
double lo, t;
cin >> n;
for(int p=1; p<=n*(n-1)/2; p++)
q[p] = p;//???????
for(i=1; i<=n; i++)
cin >> a[i].x >> a[i].y >> a[i].z;
for(j=1; j<=n-1; j++)
for(k=j+1; k<=n; k++)
{
lo = sqrt(((a[j].x-a[k].x)*(a[j].x-a[k].x)+
(a[j].y-a[k].y)*(a[j].y-a[k].y)+
(a[j].z-a[k].z)*(a[j].z-a[k].z))*1.0);//????
co++;
l[co] = lo;
}
for(int x=1; x<=n*(n-1)/2-1; x++)
for(int y=1; y<=n*(n-1)/2-x; y++)
if(l[y] < l[y+1])
{
t = l[y];
l[y] = l[y+1];
l[y+1] = t;//????
temp = q[y];
q[y] = q[y+1];
q[y+1] = temp;//????????
}
for(int x=1; x<=n*(n-1)/2; x++)
{
co1++;
for(int y=1; y<=n; y++)
{
if(q[co1] > n-y)
q[co1] -= n-y;
else
{
x1 = y;
y1 = q[co1] + y;//???????
break;
}
}
cout << "(" << a[x1].x << "," << a[x1].y << "," << a[x1].z << ")-("
<< a[y1].x << "," << a[y1].y << "," << a[y1].z << ")=" << fixed <<
setprecision(2) << l[x] << endl;
}
return 0;
} | 64 |
31,647 | int main()
{
float a[100][9],b[20][4],max=0;//1-3???????4-5??????7???
int n,i,j,k=1;
cin>>n;
for (i=1;i<=n;i++)
{for(j=1;j<=3;j++){
cin>>b[i][j];
}}
for (i=1;i<=n-1;i++)
{for (j=i+1;j<=n;j++)
{a[k][1]=b[i][1];
a[k][2]=b[i][2];
a[k][3]=b[i][3];
a[k][4]=b[j][1];
a[k][5]=b[j][2];
a[k][6]=b[j][3];
a[k][7]=sqrt(pow((a[k][1]-a[k][4]),2)+pow((a[k][2]-a[k][5]),2)+pow((a[k][3]-a[k][6]),2));
a[k][8]=0; //??????
k++;
}
}
for(i = 1;i <= (n*n-n)/2;i++){
for (k=1;k<=(n*n-n)/2;k++)
{
if (a[k][7]>max&&a[k][8]==0)
max=a[k][7];
}
for (k=1;k<=(n*n-n)/2;k++)
{if (max==a[k][7]&&a[k][8]==0){
printf("(%.0f,%.0f,%.0f)-(%.0f,%.0f,%.0f)=%.2f\n",a[k][1],a[k][2],a[k][3],a[k][4],a[k][5],a[k][6],a[k][7]);
a[k][8]=1;
max=0;
}}
}
return 0;
}
| 64 |
31,648 |
int main()
{
int n,b,c;
scanf("%d",&n);
int i,j,sa[11],sb[11],sc[11];
for(i=0;i<n;i++)
{
scanf("%d%d%d",&sa[i],&sb[i],&sc[i]);
}
int s[51],k,y[51],z[51];
double l[51];
i=0;
for(j=0;j<n-1;j++)
{
for(k=j+1;k<n;k++)
{
s[i]=(sa[j]-sa[k])*(sa[j]-sa[k])+(sb[j]-sb[k])*(sb[j]-sb[k])+(sc[j]-sc[k])*(sc[j]-sc[k]);
l[i]=sqrt(s[i]);
y[i]=j;
z[i]=k;//??????
i++;
}
}
int e,g;
double f;
for(k=1;k<=i;k++)
{
for(j=0;j<(i-k);j++)
{
if(l[j]<l[j+1])
{
f=l[j];
l[j]=l[j+1];
l[j+1]=f;//????
e=y[j];
y[j]=y[j+1];
y[j+1]=e;
g=z[j];
z[j]=z[j+1];
z[j+1]=g;//???????
}
}
}
for(j=0;j<i;j++)
{
b=y[j];
c=z[j];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",sa[b],sb[b],sc[b],sa[c],sb[c],sc[c],l[j]);
}
return 0;
} | 64 |
31,649 | int main()
{
int n,j=0,b;
int a[15][3];
double s[10000];
int x[10000][2];
double p;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i][0]>>a[i][1]>>a[i][2];
}
for(int k=0;k<n-1;k++)
{
for(int m=k+1;m<n;m++)
{
s[j]=sqrt((a[k][0]-a[m][0])*(a[k][0]-a[m][0])+(a[k][1]-a[m][1])*(a[k][1]-a[m][1])+(a[k][2]-a[m][2])*(a[k][2]-a[m][2]));
x[j][0]=k;
x[j][1]=m;
j++;
}
}
for(int z=0;z<j-1;z++)
{
for(int d=0;d<j-1-z;d++)
{
if(s[d]<s[d+1])
{
p=s[d+1];
s[d+1]=s[d];
s[d]=p;
b=x[d+1][0];
x[d+1][0]=x[d][0];
x[d][0]=b;
b=x[d+1][1];
x[d+1][1]=x[d][1];
x[d][1]=b;
}
}
}
for(int g=0;g<j;g++)
{
cout<<"("<<a[x[g][0]][0]<<","<<a[x[g][0]][1]<<","<<a[x[g][0]][2]<<")"<<"-"<<"("<<a[x[g][1]][0]<<","<<a[x[g][1]][1]<<","<<a[x[g][1]][2]<<")"<<"="<<fixed<<setprecision(2)<<s[g]<<endl;
}
return 0;
}
| 64 |
31,650 | //**********************************
//**** ?????? *****
//**** 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 |
31,651 | int n, t = 1;
struct dian
{
int x;
int y;
int z;
}a[11], *p = &a[1];
struct ju
{
int p1;
int p2;
double d;
}b[100], temp;
void fsort(int k)
{
int i;
for(i = k + 1; i <= t; i++)
{
if(b[k].d < b[i].d)
{
temp = b[k];
b[k] = b[i];
b[i] = temp;
}
}
}
int main()
{
int i, j;
cin >> n;
cout << fixed << setprecision(2);
for(i = 1; i <= n; i++)
{
cin >> p->x >> p->y >> p->z;
p++;
}
for(i = 1; i <= n - 1; i++)
{
for(j = i + 1; j <= n; j++)
{
b[t].p1 = i;
b[t].p2 = j;
b[t].d = pow(pow(a[i].x - a[j].x, 2.0) + pow(a[i].y - a[j].y, 2.0) + pow(a[i].z - a[j].z, 2.0), 0.5);
t++;
}
}
t--;
for(i = 1; i < t; i++)
{
fsort(i);
}
for(i = 1; i < t; i++)
{
if(b[i].d == b[i + 1].d)
{
if(b[i].p1 > b[i + 1].p1)
{
temp = b[i + 1];
b[i + 1] = b[i];
b[i] = temp;
}
else
{
if(b[i].p1 == b[i + 1].p1 && b[i].p2 > b[i + 1].p2)
{
temp = b[i + 1];
b[i + 1] = b[i];
b[i] = temp;
}
}
}
}
for(i = 1; i <= t; i++)
{
cout << "(" << a[b[i].p1].x << "," << a[b[i].p1].y << "," << a[b[i].p1].z << ")" << "-" << "(" << a[b[i].p2].x << "," << a[b[i].p2].y << "," << a[b[i].p2].z << ")" << "=" << b[i].d << endl;
}
return 0;
}
| 64 |
31,652 | int main(){
int n,a[30],b[45],c[45],p=0,e,q,g,i,t,k,s,x,h,j,v;
double dis[45],mid;
scanf("%d",&n);
for(i=0;i<(3*n);i++){
scanf("%d",&a[i]);
}
for(t=0;t<n;t++){
for(k=t+1;k<n;k++){
b[p]=t;c[p]=k;
e=(a[3*t]-a[3*k])*(a[3*t]-a[3*k])+(a[3*t+1]-a[3*k+1])*(a[3*t+1]-a[3*k+1])+(a[3*t+2]-a[3*k+2])*(a[3*t+2]-a[3*k+2]);
dis[p]=sqrt(e);
p++;
}
}
for(s=1;s<=p;s++){
for(x=0;x<p-s;x++){
if(dis[x]<dis[x+1]){
mid=dis[x+1];
dis[x+1]=dis[x];
dis[x]=mid;
q=b[x+1];
b[x+1]=b[x];
b[x]=q;
g=c[x+1];
c[x+1]=c[x];
c[x]=g;
}
}
}
for(h=0;h<p;h++){
j=3*b[h];v=3*c[h];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[j],a[j+1],a[j+2],a[v],a[v+1],a[v+2],dis[h]);
}
return 0;
}
| 64 |
31,653 | int main()
{
float point[10][3],distant[45],t;
int n,i,j,k=0,p,d[45][2];
cin>>n;
for(i=0;i<n;i++)
for(j=0;j<3;j++)
cin>>point[i][j]; //i???????j?????????
for(i=0;i<n;i++)
for(j=i+1;j<n;j++,k++){//distant????????????d??????????????
distant[k]=sqrt(pow((point[i][0]-point[j][0]),2)+pow((point[i][1]-point[j][1]),2)+pow((point[i][2]-point[j][2]),2));
d[k][0]=i;d[k][1]=j;}
for(i=1;i<n*(n-1)/2;i++) //?????????distance????
for(j=0;j<n*(n-1)/2-i;j++)
if(distant[j]<distant[j+1]){
t=distant[j];
distant[j]=distant[j+1];
distant[j+1]=t;
p=d[j][0];
d[j][0]=d[j+1][0];
d[j+1][0]=p;
p=d[j][1];
d[j][1]=d[j+1][1];
d[j+1][1]=p;}
for(k=0;k<(n*(n-1)/2);k++)//????
cout<<'('<<fixed<<setprecision(0)<<point[d[k][0]][0]<<','<<point[d[k][0]][1]<<','<<
point[d[k][0]][2]<<')'<<'-'<<'('<<point[d[k][1]][0]<<','<<
point[d[k][1]][1]<<','<<point[d[k][1]][2]<<')'<<'='<<fixed<<setprecision(2)<<distant[k]<<endl;
return 0;
} | 64 |
31,654 |
int main(int argc, char* argv[])
{
int n;
scanf("%d",&n);
int x[10],y[10],z[10];
int i,j;
for(i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
float l[46];
int p1[46];
int p2[46];
int zz=0;
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
l[zz]=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]));
p1[zz]=i;
p2[zz]=j;
zz++;
}
}
float lamp2;
int lamp;
for(i=0;i<zz;i++){
for(j=i+1;j<zz;j++){
if(l[j]>l[i]){
lamp2=l[j];
l[j]=l[i];
l[i]=lamp2;
lamp=p1[j];
p1[j]=p1[i];
p1[i]=lamp;
lamp=p2[j];
p2[j]=p2[i];
p2[i]=lamp;
}
if(l[j]==l[i]){
if(p1[i]>p1[j]||(p1[i]==p1[j]&&p2[i]>p2[j])){
lamp2=l[j];
l[j]=l[i];
l[i]=lamp2;
lamp=p1[j];
p1[j]=p1[i];
p1[i]=lamp;
lamp=p2[j];
p2[j]=p2[i];
p2[i]=lamp;
}}
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[p1[i]],y[p1[i]],z[p1[i]],x[p2[i]],y[p2[i]],z[p2[i]],l[i]);
}
return 0;
}
| 64 |
31,655 |
int main(){
int n,x[20],y[20],z[20];
float dis[20][20],a[400];
int k=0;
cin>>n;
for(int i=0;i<n;i++)
cin>>x[i]>>y[i]>>z[i];
for(int i=0;i<n;i++)
for(int j=i+1;j<n;j++)
{
a[k]=dis[i][j]=sqrt((float)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])));
k++;
}
for(int i=0;i<k-1;i++)
for(int j=0;j<k-i;j++)
if(a[j]<a[j+1])
swap(a[j],a[j+1]);
for(int g=0;g<k;g++)
{
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if (a[g]!=a[g+1]&&a[g]==dis[i][j])
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[i],y[i],z[i],x[j],y[j],z[j],a[g]);
}
}
}
}
return 0;
} | 64 |
31,656 | int main()
{
int n,i=0,j=0,k=0;;
double x[10],y[10],z[10],d[100],t,s,c[10][10]={0};
cin>>n;
for(int i=0;i<n;i++)
{
cin>>x[i]>>y[i]>>z[i];
}
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
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(int k=0;k<(n*(n-1)/2)-1;k++)
{
for(int l=0;l<(n*(n-1)/2)-1;l++)
{
if(d[l]<d[l+1])
{
t=d[l+1];
d[l+1]=d[l];
d[l]=t;
}
}
}
for(int k=0;k<(n*(n-1)/2);k++)
{
s=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(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]))&&s==0&&c[i][j]==0)
{
cout<<"("<<fixed<<setprecision(0)<<x[i]<<","<<fixed<<setprecision(0)<<y[i]<<","<<fixed<<setprecision(0)<<z[i]<<")-("<<fixed<<setprecision(0)<<x[j]<<","<<fixed<<setprecision(0)<<y[j]<<","<<fixed<<setprecision(0)<<z[j]<<")="<<fixed<<setprecision(2)<<d[k]<<endl;
s+=1;
c[i][j]+=1;
}
}
}
}
return 0;
} | 64 |
31,657 | int main()
{
int n,i,j,count,il,jl;
int a[10][3];
double m;
double b[45];
int c[45][2];
scanf("%d",&n);
count=0;
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++) //????????
{
m=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1])+(a[i][2]-a[j][2])*(a[i][2]-a[j][2]));
b[count]=m;
c[count][0]=i;
c[count][1]=j;
count=count+1;
}
}
for(i=0;i<(n-1)*n/2;i++)
{
for(j=0;j<(n-1)*n/2-1;j++)
{
if(b[j]<b[j+1])
{
m=b[j+1];
b[j+1]=b[j];
b[j]=m;
il=c[j+1][0];
c[j+1][0]=c[j][0];
c[j][0]=il;
jl=c[j+1][1];
c[j+1][1]=c[j][1];
c[j][1]=jl;
}
if(b[j]==b[j+1])
{
m=b[j+1];
b[j+1]=b[j];
b[j]=m;
il=c[j+1][0];
c[j+1][0]=c[j][0];
c[j][0]=il;
jl=c[j+1][1];
c[j+1][1]=c[j][1];
c[j][1]=jl;
}
}
}
for(i=0;i<(n-1)*n/2;i++)
{
for(j=0;j<(n-1)*n/2-1;j++)
{
if(b[j]==b[j+1])
{
if(c[j][0]>c[j+1][0]||(c[j][0]==c[j+1][0]&&c[j][1]>c[j+1][1]))
{
m=b[j+1];
b[j+1]=b[j];
b[j]=m;
il=c[j+1][0];
c[j+1][0]=c[j][0];
c[j][0]=il;
jl=c[j+1][1];
c[j+1][1]=c[j][1];
c[j][1]=jl;
}
}
}
}
for(i=0;i<n*(n-1)/2;i++)
{
il=c[i][0];
jl=c[i][1];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[il][0],a[il][1],a[il][2],a[jl][0],a[jl][1],a[jl][2],b[i]);
}
return 0;
} | 64 |
31,658 | 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 |
31,659 | int main()
{
int x[10],y[10],z[10];
int n,i,j,p,m,h;
double k,l[10][10];
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++)
{
k=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);
l[i][j]=sqrt(k);
}
for(h=1;h<=n*(n-1)/2;h++)
{
double max=0;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(max<l[i][j])
{
max=l[i][j];
p=i,m=j;
}
cout<<"("<<x[p]<<","<<y[p]<<","<<z[p]<<")-("<<x[m]<<","<<y[m]<<","<<z[m]<<")="<< fixed << setprecision(2)<<l[p][m]<<endl;
l[p][m]=0;
}
return 0;
} | 64 |
31,660 | int main()
{
int n,i,j,k;//??????
int x[10],y[10],z[10];//?????????
float d[90]={0},temp=0;//?????????0
cin>>n;
for(i=0;i<=n-1;++i)
cin>>x[i]>>y[i]>>z[i];//????
for(i=0;i<=n-2;++i)
{
for(j=i+1;j<=n-1;++j)
{
d[10*i+j]=sqrt((double)((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j])));//????
}
}
for(j=1;j<=(n-1)*n/2;++j)//???? ??????
{
for(i=1;i<=89;++i)
{
if(d[i]==0) continue;//???0 ?????? continue
if(d[i]>temp)
{
temp=d[i];//????
k=i;
}
}
cout<<"("<<x[k/10]<<","<<y[k/10]<<","<<z[k/10]<<")"<<"-"<<"("<<x[k%10]<<","<<y[k%10]<<","<<z[k%10]<<")"<<"="<<fixed<<setprecision(2)<<temp<<endl;//??
d[k]=0;//???0
temp=0;//???0
k=0;//???0 ??????
}
return 0;
}
| 64 |
31,661 | 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 |
31,662 | /**
* @file 1000012800_3.cpp
* @author ??
* @date 2010-12-15
* @description
* ??????:??????
*/
int main()
{
int n, dot[100][3], count = -1;
double counter[5000][3], tmp;
cin >> n;
for (int i = 0; i < n; i++)
cin >> dot[i][0] >> dot[i][1] >> dot[i][2];
for (int i = 0; i < n - 1; i++)
for (int j = i + 1; j < n; j++)
{
count++;
counter[count][0] = sqrt((double)((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])));
counter[count][1] = i;
counter[count][2] = j;
}
for (int i = 0; i < count; i++)
for (int j = count; j > i; j--)
{
if (counter[j][0] > counter[j - 1][0])
{
for (int k = 0; k < 3; k++)
{
tmp = counter[j][k];
counter[j][k] = counter[j - 1][k];
counter[j - 1][k] = tmp;
}
}
}
for (int i = 0; i <= count; i++)
{
cout << "(" << dot[(int)counter[i][1]][0] << "," <<
dot[(int)counter[i][1]][1] << "," <<dot[(int)counter[i][1]][2] <<
")-("<< dot[(int)counter[i][2]][0] << "," << dot[(int)counter[i][2]][1] <<
"," << dot[(int)counter[i][2]][2] << ")=" << setprecision(2) << fixed << counter[i][0] << endl;
}
return 0;
}
| 64 |
31,663 | int p[100][3]; //????????n?????
struct Distance
{
int p1,p2; //????p1?p2???
double d;
};
int main()
{
int n;
cin>>n;
int i,j,k;
for(i=0;i<n;i++)
for(j=0;j<3;j++)
cin>>p[i][j];
struct Distance a[100*100+10],temp;
int m=0; //????m
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
double sum=0;
for(k=0;k<3;k++)
sum+=pow(p[i][k]*1.0-p[j][k]*1.0,2*1.0);
a[m].d=sqrt(sum);
a[m].p1=i; //????????????Distance a[m]
a[m].p2=j;
m++;
}
for(i=0;i<m;i++) //????
for(j=0;j<m-i;j++)
if(a[j].d<a[j+1].d)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for(i=0;i<m;i++)
{
cout<<"("<<p[a[i].p1][0]<<","<<p[a[i].p1][1]<<","<<p[a[i].p1][2]<<")"<<"-"
<<"("<<p[a[i].p2][0]<<","<<p[a[i].p2][1]<<","<<p[a[i].p2][2]<<")"<<"="
<<fixed<<setprecision(2)<<a[i].d<<endl;
}
return 0;
}
| 64 |
31,664 | int main(){
int x[1000],y[1000],z[1000],n,i,m,j,u[1000],v[1000],c,d;
double s[100],b;
b=0;
c=0;
d=0;
m=0;
scanf("%d",&n);
for( i=0;i<n;i++)
scanf("%d%d%d",&x[i],&y[i],&z[i]);
for(i=0;i<n;i++){
for(int j=n-1;j>i;j--){
b=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])+(z[i]-z[j])*(z[i]-z[j]);
s[m]= sqrt(b);
u[m]=i;
v[m]=j;
m++;
}
}
for(i=0;i<n*(n-1)/2;i++){
if(n==2)
break;
for(j=0;j<n*(n-1)/2;j++){
if(s[j]<s[j+1]){
b=s[j];
s[j]=s[j+1];
s[j+1]=b;
c=u[j];
u[j]=u[j+1];
u[j+1]=c;
d=v[j];
v[j]=v[j+1];
v[j+1]=d;
}
}
}
for(i=0;i<n*(n-1)/2;i++){
if(n==2)
break;
if(s[i]==s[i+1]){
if(u[i]>u[i+1]){
c=u[i];
u[i]=u[i+1];
u[i+1]=c;
d=v[i];
v[i]=v[i+1];
v[i+1]=d;
}
if(u[i]==u[i+1]){
if(v[i]>v[i+1]){
c=u[i];
u[i]=u[i+1];
u[i+1]=c;
d=v[i];
v[i]=v[i+1];
v[i+1]=d;
}
}
}
}
for(i=0;i<n*(n-1)/2;i++){
if(n==2)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[u[0]],y[u[0]],z[u[0]],x[v[0]],y[v[0]],z[v[0]],s[0]);
else{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[u[i]],y[u[i]],z[u[i]],x[v[i]],y[v[i]],z[v[i]],s[i]);
}
}
return 0;
}
| 64 |
31,665 | int main(){
int n;
scanf("%d",&n);
int i,j=0,x[100],y[100],z[100],nlx[100],nly[100],nlz[100],nfx[100],nfy[100],nfz[100];
for(i=0;i<n;i++){
scanf("%d %d %d",&x[i],&y[i],&z[i]);
}
double d,jl[45];
for(i=0;i<n-1;i++){
for(int k=i+1;k<n;k++){
d=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]);
jl[j]=sqrt(d);
nfx[j]=x[i];
nfy[j]=y[i];
nfz[j]=z[i];
nlx[j]=x[k];
nly[j]=y[k];
nlz[j]=z[k];
j++;
}
}
int result;
result=n*(n-1)/2;
for(int k=1;k<=result;k++){
double e;
for(j=0;j<result-k;j++){
if(jl[j]<jl[j+1]){
e=jl[j+1];
jl[j+1]=jl[j];
jl[j]=e;
e=nfx[j+1];
nfx[j+1]=nfx[j];
nfx[j]=e;
e=nfy[j+1];
nfy[j+1]=nfy[j];
nfy[j]=e;
e=nfz[j+1];
nfz[j+1]=nfz[j];
nfz[j]=e;
e=nlx[j+1];
nlx[j+1]=nlx[j];
nlx[j]=e;
e=nly[j+1];
nly[j+1]=nly[j];
nly[j]=e;
e=nlz[j+1];
nlz[j+1]=nlz[j];
nlz[j]=e;
}
}
}
for(j=0;j<result;j++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",nfx[j],nfy[j],nfz[j],nlx[j],nly[j],nlz[j],jl[j]);
}
return 0;
}
| 64 |
31,666 | int main(){
int n,i,j;
scanf("%d",&n);
struct point
{
int x;
int y;
int z;
}
point[10];
for(i=0;i<n;i++){
scanf("%d%d%d",&point[i].x,&point[i].y,&point[i].z);
}
struct len
{
double s;
struct point p1,p2;
}
len[45];
int k=0;
for(j=0;j<n-1;j++){
for(i=j+1;i<n;i++){
len[k].s=sqrt((point[j].x-point[i].x)*(point[j].x-point[i].x)+(point[j].y-point[i].y)*(point[j].y-point[i].y)+(point[j].z-point[i].z)*(point[j].z-point[i].z));
len[k].p1.x=point[j].x;
len[k].p1.y=point[j].y;
len[k].p1.z=point[j].z;
len[k].p2.x=point[i].x;
len[k].p2.y=point[i].y;
len[k].p2.z=point[i].z;
k++;
}
}
double e;
int f,g,h,l,m,o;
for(j=1;j<=k;j++){
for(i=k-1;i>j-1;i--){
if(len[i-1].s<len[i].s){
e=len[i-1].s; f=len[i-1].p1.x; g=len[i-1].p2.x; h=len[i-1].p1.y; l=len[i-1].p2.y; m=len[i-1].p1.z; o=len[i-1].p2.z;
len[i-1].s=len[i].s; len[i-1].p1.x=len[i].p1.x; len[i-1].p2.x=len[i].p2.x; len[i-1].p1.y=len[i].p1.y; len[i-1].p2.y=len[i].p2.y; len[i-1].p1.z=len[i].p1.z;len[i-1].p2.z=len[i].p2.z;
len[i].s=e; len[i].p1.x=f; len[i].p2.x=g; len[i].p1.y=h; len[i].p2.y=l; len[i].p1.z=m; len[i].p2.z=o;
}
}
}
for(i=0;i<k;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",len[i].p1.x,len[i].p1.y,len[i].p1.z,len[i].p2.x,len[i].p2.y,len[i].p2.z,len[i].s);
}
return 0;
} | 64 |
31,667 | /*
* jiegou_4.cpp
* ???????
* Created on: 2011-1-2
* Author: Wang Ju
*/
struct distance //?????distance
{
double a[3]; //??1
double b[3]; //??2
double distance; //???????
};
int factorial(int i) //????facortial,??i?????????
{
return (i*(i+1))/2;
}
double oper(double x1, double y1, double z1, double x2, double y2, double z2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
//????oper,???????
}
int main() //????
{
int n, i, j, m; //????
cin>>n; //??????n
double x[n][3];
for(i=0; i<n; i++)
{
cin>>x[i][0]>>x[i][1]>>x[i][2]; //????
}
m=factorial(n-1);//m?distance???
struct distance dot[m]; //??m?distance??
int k=0;
for(i=1; i<n; i++)
for(j=i+1; j<=n; j++)
{
dot[k].a[0]=x[i-1][0];
dot[k].a[1]=x[i-1][1];
dot[k].a[2]=x[i-1][2];
dot[k].b[0]=x[j-1][0];
dot[k].b[1]=x[j-1][1];
dot[k].b[2]=x[j-1][2];
dot[k].distance=oper(dot[k].a[0], dot[k].a[1], dot[k].a[2], dot[k].b[0], dot[k].b[1], dot[k].b[2]);
k++;
//?????????????????????????
}
for(i=0; i<m-1; i++)
for(j=0; j<m-i-1; j++)
{
if(dot[j].distance<dot[j+1].distance)
{
struct distance temp=dot[j];
dot[j]=dot[j+1];
dot[j+1]=temp; //?????
}
}
for(i=0; i<m; i++)
{
cout<<fixed<<setprecision(0)<<"("<<dot[i].a[0]<<","<<dot[i].a[1]<<","<<dot[i].a[2]<<")-("<<dot[i].b[0]<<
","<<dot[i].b[1]<<","<<dot[i].b[2]<<")=";
cout<<fixed<<setprecision(2)<<dot[i].distance<<endl;
} //???????????
return 0; //???0?
}
| 64 |
31,668 | void dx(int x, int y);
void ds(double x, double y);
int main()
{
int n,i,j,q,p,l,k;
scanf("%d",&n);
p=0.5*n*(n-1);
int x[n],y[n],z[n];
double o;
double jl[p];
int xx[p],yy[p],zz[p],xa[p],ya[p],za[p];
q=0;
for(i=0;i<n;i++)
{scanf("%d%d%d",&x[i],&y[i],&z[i]);}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
xx[q]=x[i];
yy[q]=y[i];
zz[q]=z[i];
xa[q]=x[j];
ya[q]=y[j];
za[q]=z[j];
jl[q]=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]));
q++;
}
}
for(i=0;i<p;i++)
{
for(j=0;j<p-1;j++)
{
if(jl[j]<jl[j+1])
{
k=xx[j];
xx[j]=xx[j+1];
xx[j+1]=k;
k=yy[j];
yy[j]=yy[j+1];
yy[j+1]=k;
k=zz[j];
zz[j]=zz[j+1];
zz[j+1]=k;
k=ya[j];
ya[j]=ya[j+1];
ya[j+1]=k;
k=xa[j];
xa[j]=xa[j+1];
xa[j+1]=k;
k=za[j];
za[j]=za[j+1];
za[j+1]=k;
o=jl[j];
jl[j]=jl[j+1];
jl[j+1]=o;
}
}
}
for(i=0;i<p;i++)
{printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",xx[i],yy[i],zz[i],xa[i],ya[i],za[i],jl[i]);}
return 0;
}
void dx(int *x, int *y)
{
int e=0;
e=*x;
*x=*y;
*y=e;
return;
}
void ds(double *x, double *y)
{
double r=0;
r=*x;
*x=*y;
*y=r;
return;
}
| 64 |
31,669 |
typedef struct Point
{
int x,y,z;
}Point;
typedef struct Distance
{
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 *)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[11];
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 |
31,670 | int dist(int x1,int y1,int z1,int x2,int y2,int z2)
{
return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);
}
int main()
{
int x[10],y[10],z[10],d[100],i,j,n,m,k,a1[100],b1[100],c1[100],a2[100],b2[100],c2[100];
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+1;j<n;j++)
{
d[k]=dist(x[i],y[i],z[i],x[j],y[j],z[j]);
a1[k]=x[i];
b1[k]=y[i];
c1[k]=z[i];
a2[k]=x[j];
b2[k]=y[j];
c2[k]=z[j];
k++;
}
}
for(i=0;i<k-1;i++)
for(j=0;j<k-i-1;j++)
{
if(d[j]<d[j+1])
{
m=d[j];
d[j]=d[j+1];
d[j+1]=m;
m=a1[j];
a1[j]=a1[j+1];
a1[j+1]=m;
m=b1[j];
b1[j]=b1[j+1];
b1[j+1]=m;
m=c1[j];
c1[j]=c1[j+1];
c1[j+1]=m;
m=a2[j];
a2[j]=a2[j+1];
a2[j+1]=m;
m=b2[j];
b2[j]=b2[j+1];
b2[j+1]=m;
m=c2[j];
c2[j]=c2[j+1];
c2[j+1]=m;
}
}
for(i=0;i<k;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a1[i],b1[i],c1[i],a2[i],b2[i],c2[i],sqrt(d[i]));
return 0;
} | 64 |
31,671 | int a[1000];
int b[1000];
int c[1000];
float sum[1000];
float dis[1000];
int x[1000];
int y[1000];
int main(){
int n=0,d=0,i=0,r=0,l=0,f=0,k=0;
float e=0;
for(i=0;i<n;i++){
sum[i]=0;
dis[i]=0;
}
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d %d %d ",&a[i],&b[i],&c[i]);
}
for(i=0;i<n-1;i++){
for(r=i+1;r<n;r++){
sum[l]=(a[i]-a[r])*(a[i]-a[r])+(b[i]-b[r])*(b[i]-b[r])+(c[i]-c[r])*(c[i]-c[r]);
dis[l]=sqrt(sum[l]);
x[l]=i;
y[l]=r;
l++;}
}
for(f=0;f<n*(n-1)/2;f++){
for(d=0;d<n*(n-1)/2-1; d++){
if(dis[d]<dis[d+1]){
e=dis[d];
dis[d]=dis[d+1];
dis[d+1]=e;
k=x[d];
x[d]=x[d+1];
x[d+1]=k;
k=y[d];
y[d]=y[d+1];
y[d+1]=k;
}
}
}
for(f=0;f<n*(n-1)/2;f++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[x[f]],b[x[f]],c[x[f]],a[y[f]],b[y[f]],c[y[f]],dis[f]);}
return 0;
} | 64 |
31,672 | struct Line
{
int n1;
int n2;
double dis;
};
int main()
{
double distance(double a[3],double b[3]);
struct Line l[55];
double num[10][3],td;
int n,i,j,k,p,q,t,num1[10][3];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lf%lf%lf",&num[i][0],&num[i][1],&num[i][2]);
}
k=0;
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
l[k].dis=distance(num[i],num[j]);
l[k].n1=i;
l[k].n2=j;
k++;
}
}
for(q=1;q<k;q++)
{
for(p=0;p<k-q;p++)
{
if(l[p].dis<l[p+1].dis)
{
t=l[p].n1;l[p].n1=l[p+1].n1;l[p+1].n1=t;
t=l[p].n2;l[p].n2=l[p+1].n2;l[p+1].n2=t;
td=l[p].dis;l[p].dis=l[p+1].dis;l[p+1].dis=td;
}
}
}
for(i=0;i<n;i++)
{
num1[i][0]=(int)num[i][0];
num1[i][1]=(int)num[i][1];
num1[i][2]=(int)num[i][2];
}
for(i=0;i<k;i++)
{
p=l[i].n1;
q=l[i].n2;
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",num1[p][0],num1[p][1],num1[p][2],num1[q][0],num1[q][1],num1[q][2],l[i].dis);
}
return 0;
}
double distance(double a[3],double b[3])
{
double m;
m=sqrt((a[0]-b[0])*(a[0]-b[0])+(a[1]-b[1])*(a[1]-b[1])+(a[2]-b[2])*(a[2]-b[2]));
return m;
}
| 64 |
31,673 | 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 |
31,674 | int main()
{
double cd[1000],s;
struct zuobiao{int x,y,z;}zuobiao[100];
struct jl{int q,w,e,r,t,u;}jl[1000];
int i,j,n,k,a,b,c,d,f,g;
scanf("%d",&n);
k=0;
for(i=0;i<n;i++)
scanf("%d%d%d",&(zuobiao[i].x),&(zuobiao[i].y),&(zuobiao[i].z));
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
cd[k]=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));
jl[k].q=zuobiao[i].x;
jl[k].w=zuobiao[i].y;
jl[k].e=zuobiao[i].z;
jl[k].r=zuobiao[j].x;
jl[k].t=zuobiao[j].y;
jl[k].u=zuobiao[j].z;
k=k+1;
}
}
for(j=1;j<=k;j++)
{
for(i=0;i<k-j;i++)
{
if(cd[i]<cd[i+1])
{
s=cd[i];cd[i]=cd[i+1];cd[i+1]=s;
a=jl[i].q;
jl[i].q=jl[i+1].q;
jl[i+1].q=a;
b=jl[i].w;
jl[i].w=jl[i+1].w;
jl[i+1].w=b;
c=jl[i].e;
jl[i].e=jl[i+1].e;
jl[i+1].e=c;
d=jl[i].r;
jl[i].r=jl[i+1].r;
jl[i+1].r=d;
f=jl[i].t;
jl[i].t=jl[i+1].t;
jl[i+1].t=f;
g=jl[i].u;
jl[i].u=jl[i+1].u;
jl[i+1].u=g;
}
}
}
for(i=0;i<k;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",jl[i].q,jl[i].w,jl[i].e,jl[i].r,jl[i].t,jl[i].u,cd[i]);
return 0;
} | 64 |
31,675 | 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=0;i<h;i++)
{
for(k=0;k<h-1-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,676 | int main(){
int n,i,j,k=0,p,q;
double t;
scanf("%d",&n);
double x[200];
double y[200];
double z[200];
double jl[200][200];
double jljl[200];
double dhi[200];
double dhj[200];
for(i=0;i<n;i++){
scanf("%lf",&(x[i]));
scanf("%lf",&(y[i]));
scanf("%lf",&(z[i]));
}
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
jl[i][j]=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])));
jljl[k]=jl[i][j];
dhi[k]=i;
dhj[k]=j;
k++;
}
}
for(i=0;i<n*(n-1)/2;i++){
for(j=n*(n-1)/2-1;j>i;j--){
if(jljl[j]>jljl[j-1]){
t=jljl[j];
jljl[j]=jljl[j-1];
jljl[j-1]=t;
t=dhi[j];
dhi[j]=dhi[j-1];
dhi[j-1]=t;
t=dhj[j];
dhj[j]=dhj[j-1];
dhj[j-1]=t;
}
}
}
k=0;
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
jl[i][j]=jljl[k];
p=(int)dhi[k];
q=(int)dhj[k];
k++;
printf("(%.0lf,%.0lf,%.0lf)-(%.0lf,%.0lf,%.0lf)=%.2lf\n",x[p],y[p],z[p],x[q],y[q],z[q],jl[i][j]);
}
}
return 0;
}
| 64 |
31,677 | 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 |
31,678 |
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 |
31,679 | double swap(double*x,double*y);
int main()
{
int p,n,i,j;
double q,x[11],y[11],z[11],px,py,pz,x1[46],y1[46],z1[46],x2[46],y2[46],z2[46];
double l[46]={0};
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lf%lf%lf",&x[i],&y[i],&z[i]);
}
p=0;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
x1[p]=x[i];y1[p]=y[i];z1[p]=z[i];x2[p]=x[j];y2[p]=y[j];z2[p]=z[j];
px=x[i]-x[j];py=y[i]-y[j];pz=z[i]-z[j];q=pow(px,2)+pow(py,2)+pow(pz,2);
l[p]=pow(q,0.5);p++;
}
}
p--;
for(i=p;i>=0;i--)
{
for(j=0;j<p;j++)
{
if(l[j]<l[j+1])
{
swap(&l[j],&l[j+1]);
swap(&x1[j],&x1[j+1]);swap(&y1[j],&y1[j+1]);swap(&z1[j],&z1[j+1]);
swap(&x2[j],&x2[j+1]);swap(&y2[j],&y2[j+1]);swap(&z2[j],&z2[j+1]);
}
}
}
for(i=0;i<=p;i++)
{
printf("(%g,%g,%g)-(%g,%g,%g)=%.2lf\n",x1[i],y1[i],z1[i],x2[i],y2[i],z2[i],l[i]);
}
return 0;
}
double swap(double*x,double*y)
{
double t;
t=*x;*x=*y;*y=t;
return 0;
}
| 64 |
31,680 | 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 |
31,681 | int main()
{
int b,c,d,h,i,j,k,l,m,n,o,s;
struct{
int x,y,z;
}point[10];
struct{
struct{
int p1,p2,p3;
}p[50];
struct{
int q1,q2,q3;
}q[50];
double r;
}dis[50];
double g;
scanf("%d",&n);
for(int a=0;a<n;a++)
{
scanf("%d%d%d",&(point[a].x),&(point[a].y),&(point[a].z));
}
s=n*(n-1)/2;
o=0;
for(c=0;c<n-1;c++)
{
d=c+1;
for(b=o;b<s;b++)
{
dis[b].r=sqrt((point[c].x-point[d].x)*(point[c].x-point[d].x)+(point[c].y-point[d].y)*(point[c].y-point[d].y)+(point[c].z-point[d].z)*(point[c].z-point[d].z));
dis[b].p[b].p1=point[c].x;
dis[b].p[b].p2=point[c].y;
dis[b].p[b].p3=point[c].z;
dis[b].q[b].q1=point[d].x;
dis[b].q[b].q2=point[d].y;
dis[b].q[b].q3=point[d].z;
d++;
o++;
if(d<n)
continue;
else
break;
}
}
for(int e=1;e<=s;e++)
{
for(int f=0;f<s-e;f++)
{
if(dis[f].r<dis[f+1].r)
{
g=dis[f+1].r;
dis[f+1].r=dis[f].r;
dis[f].r=g;
h=dis[f+1].p[f+1].p1;
dis[f+1].p[f+1].p1=dis[f].p[f].p1;
dis[f].p[f].p1=h;
i=dis[f+1].p[f+1].p2;
dis[f+1].p[f+1].p2=dis[f].p[f].p2;
dis[f].p[f].p2=i;
j=dis[f+1].p[f+1].p3;
dis[f+1].p[f+1].p3=dis[f].p[f].p3;
dis[f].p[f].p3=j;
k=dis[f+1].q[f+1].q1;
dis[f+1].q[f+1].q1=dis[f].q[f].q1;
dis[f].q[f].q1=k;
l=dis[f+1].q[f+1].q2;
dis[f+1].q[f+1].q2=dis[f].q[f].q2;
dis[f].q[f].q2=l;
m=dis[f+1].q[f+1].q3;
dis[f+1].q[f+1].q3=dis[f].q[f].q3;
dis[f].q[f].q3=m;
}
}
}
for(b=0;b<s;b++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dis[b].p[b].p1,dis[b].p[b].p2,dis[b].p[b].p3,dis[b].q[b].q1,dis[b].q[b].q2,dis[b].q[b].q3,dis[b].r);
}
return 0;
} | 64 |
31,682 | main()
{
int x[10],y[10],z[10],a1[50],b1[50],c1[50],a2[50],b2[50],c2[50],n,i,j,k,m;
float d[50],q;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&x[i]);
scanf("%d",&y[i]);
scanf("%d",&z[i]);
}
k=0;
for(i=0;i<n;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]));
a1[k]=x[i];
b1[k]=y[i];
c1[k]=z[i];
a2[k]=x[j];
b2[k]=y[j];
c2[k]=z[j];
k++;
}
}
for(i=0;i<(n*(n-1))/2-1;i++)
{
for(j=0;j<(n*(n-1))/2-1-i;j++)
{
if (d[j]<d[j+1])
{
q=d[j+1];
d[j+1]=d[j];
d[j]=q;
m=a1[j+1];
a1[j+1]=a1[j];
a1[j]=m;
m=b1[j+1];
b1[j+1]=b1[j];
b1[j]=m;
m=c1[j+1];
c1[j+1]=c1[j];
c1[j]=m;
m=a2[j+1];
a2[j+1]=a2[j];
a2[j]=m;
m=b2[j+1];
b2[j+1]=b2[j];
b2[j]=m;
m=c2[j+1];
c2[j+1]=c2[j];
c2[j]=m;
}
}
}
for(i=0;i<(n*(n-1))/2;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a1[i],b1[i],c1[i],a2[i],b2[i],c2[i],d[i]);
}
} | 64 |
31,683 | struct loc
{
int x;
int y;
int z;
};
int main()
{
struct loc a[10];
double len[10][10],max;
int n,i,j,k,no1,no2;
memset(len,0,sizeof(len));
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-1;i++)
for (j=i+1;j<n;j++)
len[i][j]=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y)+(a[i].z-a[j].z)*(a[i].z-a[j].z));
for (k=0;k<(n-1)*n/2;k++)
{
max=0;
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
if (len[i][j]>max)
{
max=len[i][j];
no1=i;
no2=j;
}
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[no1].x,a[no1].y,a[no1].z,a[no2].x,a[no2].y,a[no2].z,len[no1][no2]);
len[no1][no2]=0;
}
return 0;
}
| 64 |
31,684 | int main(){
int n,a,l=0,c,d;
scanf("%d",&n);
a=n*(n-1)/2;
int x[n],y[n],z[n],q[a],p[a];
double s[a],b;
for(int i=0;i<n;i++){
scanf("%d%d%d",&x[i],&y[i],&z[i]);
}
for(int i=0;i<n-1;i++){
for(int k=i+1;k<n;k++){
s[l]=sqrt((x[i]-x[k])*(x[i]-x[k])+(y[i]-y[k])*(y[i]-y[k])+(z[i]-z[k])*(z[i]-z[k]));
p[l]=i;
q[l]=k;
l++;
}
}
for(int i=1;i<=a;i++){
for(int k=0;k<a-i;k++){
if(s[k]<s[k+1]){
b=s[k];
s[k]=s[k+1];
s[k+1]=b;
c=p[k];
p[k]=p[k+1];
p[k+1]=c;
d=q[k];
q[k]=q[k+1];
q[k+1]=d;
}
}
}
for(int i=0;i<a;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",x[p[i]],y[p[i]],z[p[i]],x[q[i]],y[q[i]],z[q[i]],s[i]);
}
return 0;
}
| 64 |
31,685 | /*
* 4.cpp
*
* Created on: 2011-1-1
* Author: Administrator
*/
double f(int x1,int y1,int z1,int x2,int y2,int z2){
double d2=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);
return sqrt(d2);
}//?????
int main(){
int x[10],y[10],z[10];//??????
double d[10][10];//????
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>x[i]>>y[i]>>z[i];
for(int i=0;i<n;i++)
for(int j=0;j<i;j++){
d[i][j]=f(x[i],y[i],z[i],x[j],y[j],z[j]);
}//??????
for(int k=0;k<n*(n-1)/2;k++ ){
int a=0,b=0;
double D=0;
for(int i=0;i<n;i++)
for(int j=0;j<i;j++){
if(d[i][j]>D){
D=d[i][j];
a=i;
b=j;
}
}//????????????
cout<<"("<<x[b]<<","<<y[b]<<","<<z[b]<<")-("<<x[a]<<","<<y[a]<<","<<z[a]<<")=";
cout<<fixed<<setprecision(2)<<D<<endl;//??
d[a][b]=-1;//?????????????
}
return 0;
}
| 64 |
31,686 | double juli(double m, double n, double l);
double juli(double m, double n, double l){
double t;
t= m*m+n*n+l*l;
t=sqrt(t);
return t;
}
int main(){
int n,i,j,m;
scanf("%d",&n);
double x[11];
double y[11];
double z[11];
double k[56];
double jiawei1[56];
double jiawei2[56];
double jiawei3[56];
double jianwei1[56];
double jianwei2[56];
double jianwei3[56];
double tran;
for(i=1;i<n+1;i++){
scanf("%lf %lf %lf",&x[i],&y[i],&z[i]);
}
m=1;
for(i=1;i<1+n;i++){
for(j=i+1;j<n+1;j++){
k[m]= juli(x[i]-x[j],y[i]-y[j],z[i]-z[j]);
jiawei1[m]=x[i];
jiawei2[m]=y[i];
jiawei3[m]=z[i];
jianwei1[m]=x[j];
jianwei2[m]=y[j];
jianwei3[m]=z[j];
m=m+1;
}
}
for(i=1;i<m;i++){
for(j=i;j<m;j++){
if(k[i]<k[j]){
tran=k[i];
k[i]=k[j];
k[j]=tran;
tran=jiawei1[i];
jiawei1[i]=jiawei1[j];
jiawei1[j]=tran;
tran=jiawei2[i];
jiawei2[i]=jiawei2[j];
jiawei2[j]=tran;
tran=jiawei3[i];
jiawei3[i]=jiawei3[j];
jiawei3[j]=tran;
tran=jianwei1[i];
jianwei1[i]=jianwei1[j];
jianwei1[j]=tran;
tran=jianwei2[i];
jianwei2[i]=jianwei2[j];
jianwei2[j]=tran;
tran=jianwei3[i];
jianwei3[i]=jianwei3[j];
jianwei3[j]=tran;
}
}
}
int v=1;
for(i=1;i<m;i++){
for(j=i;j<m;j++){
if(k[i]==k[j]){
for(v=1;v<n+1;v++){
if(
(jiawei1[i]==x[v]&&jiawei1[j]!=x[v])
||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==y[v]&&jiawei2[j]!=x[v])
||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==z[v]&&jiawei3[j]!=z[v])
||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==x[v]&&jianwei1[j]!=x[v])
||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==jianwei1[j]&&jianwei2[i]==y[v]&&jianwei2[j]!=y[v])
||(jiawei1[i]==jiawei1[j]&&jiawei2[i]==jiawei2[j]&&jiawei3[i]==jiawei3[j]&&jianwei1[i]==jianwei1[j]&&jianwei2[i]==jianwei2[j]&&jianwei3[i]==z[v]&&jianwei3[j]!=z[v])
){
tran=jiawei1[i];
jiawei1[i]=jiawei1[j];
jiawei1[j]=tran;
tran=jiawei2[i];
jiawei2[i]=jiawei2[j];
jiawei2[j]=tran;
tran=jiawei3[i];
jiawei3[i]=jiawei3[j];
jiawei3[j]=tran;
tran=jianwei1[i];
jianwei1[i]=jianwei1[j];
jianwei1[j]=tran;
tran=jianwei2[i];
jianwei2[i]=jianwei2[j];
jianwei2[j]=tran;
tran=jianwei3[i];
jianwei3[i]=jianwei3[j];
jianwei3[j]=tran;
}
}
}
}
}
for(i=1;i<n*(n-1)/2+1;i++){
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",(int)jiawei1[i],(int)jiawei2[i],(int)jiawei3[i],(int)jianwei1[i],(int)jianwei2[i],(int)jianwei3[i],k[i]);
}
return 0;
}
| 64 |
31,687 |
struct dist
{
int i;
int j;
float d;
}d[45];//??i?j?????
struct node
{
int x;
int y;
int z;
}a[10];//????????
void main()
{
int n,i,j,count=0;
struct dist temp;//????????
scanf("%d",&n);
for(i=0;i<45;i++) d[i].d=0.0;//????
for(i=0;i<n;i++)
scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].z);//???
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
{
d[count].i=i;
d[count].j=j;
d[count].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));
count++;
}//??i?j?????
count=n*(n-1)/2;
for(i=0;i<count-1;i++)
for(j=0;j<count-i-1;j++)
{
if(d[j].d<d[j+1].d)
{
temp=d[j];
d[j]=d[j+1];
d[j+1]=temp;
}
}//????
for(i=0;i<count;i++)
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",a[d[i].i].x,a[d[i].i].y,a[d[i].i].z,a[d[i].j].x,a[d[i].j].y,a[d[i].j].z,d[i].d);
}
| 64 |
31,688 | /*
*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 |
31,689 | struct point{
int a,b,c;
}x[10];
int d(int k,int n)
{
int i;
for(i=n-1;k>i;i--)
k-=i;
return(n-i-1);
}
int f(int k,int n)
{
int i;
for(i=n-1;k>i;i--)
k-=i;
return(n-i+k-1);
}
void main()
{
int n,i,j,k=0,q[46],t;
float y[46];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d %d %d",&x[i].a,&x[i].b,&x[i].c);
for(i=0;i<n;i++)
for(j=i+1;j<n;j++,k++)
y[k]=sqrt((x[i].a-x[j].a)*(x[i].a-x[j].a)+(x[i].b-x[j].b)*(x[i].b-x[j].b)+(x[i].c-x[j].c)*(x[i].c-x[j].c));
for(i=0;i<=n*(n-1)/2;i++)
q[i]=i;
for(i=0;i<n*(n-1)/2-1;i++)
for(j=0;j<n*(n-1)/2-1-i;j++)
if(y[q[j]]<y[q[j+1]])
{t=q[j];
q[j]=q[j+1];
q[j+1]=t;
}
for(i=0;i<n*(n-1)/2;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",x[d(q[i]+1,n)].a,x[d(q[i]+1,n)].b,x[d(q[i]+1,n)].c,x[f(q[i]+1,n)].a,x[f(q[i]+1,n)].b,x[f(q[i]+1,n)].c,y[q[i]]);
}
}
| 64 |
31,690 | int main()
{
int n,i,j,a[80],b[80],k=0,m,code1,code2;
double S[80],t;
struct S
{
double x;
double y;
double z;
}point[13];
cin>>n;
for(i=0;i<n;i++)
cin>>point[i].x>>point[i].y>>point[i].z;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)//????Cn2
{
S[k]=sqrt((point[i].x-point[j].x)*(point[i].x-point[j].x)+(point[i].y-point[j].y)*(point[i].y-point[j].y)+(point[i].z-point[j].z)*(point[i].z-point[j].z));//???
a[k]=i;b[k]=j;
k++;//
}
for(i=0;i<k;i++)
for(j=k-1;j>i;j--)//?????
if(S[j]>S[j-1])
{
t=S[j];
S[j]=S[j-1];
S[j-1]=t;//????
m=a[j];
a[j]=a[j-1];
a[j-1]=m;//???????
m=b[j];
b[j]=b[j-1];
b[j-1]=m;//???????
}
for(i=0;i<k;i++)
{
code1=a[i];code2=b[i];
cout<<"("<<(int)point[code1].x<<","<<(int)point[code1].y<<","<<point[code1].z<<")-("
<<(int)point[code2].x<<","<<(int)point[code2].y<<","<<point[code2].z<<")=";
printf("%.2lf",S[i]);
cout<<endl;
}
return 0;
}
| 64 |
31,691 | struct dot{
int x;
int y;
int z;
}dots[10];
struct dist{
int d1;
int d2;
float dis;
}dists[45];
int cmp(const void *p1,const void *p2)
{
struct dist l1,l2;
l1=*(struct dist *)p1;
l2=*(struct dist *)p2;
if(l1.dis>l2.dis)
{
return -1;
}else if(l1.dis<l2.dis)
{
return 1;
}else{
if(l1.d1!=l2.d1)
{
return l1.d1-l2.d1;
}else{
return l1.d2-l2.d2;
}
}
return 0;
}
int main()
{
int n,i,j,t=0;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d%d%d",&dots[i].x,&dots[i].y,&dots[i].z);
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
dists[t].d1=i;
dists[t].d2=j;
dists[t].dis=sqrt((dots[i].x-dots[j].x)*(dots[i].x-dots[j].x)+(dots[i].y-dots[j].y)*(dots[i].y-dots[j].y)+(dots[i].z-dots[j].z)*(dots[i].z-dots[j].z));
t++;
}
}
qsort(&dists[0],t,sizeof(struct dist),cmp);
for(i=0;i<t;i++)printf("(%d,%d,%d)-(%d,%d,%d)=%.2f\n",dots[dists[i].d1].x,dots[dists[i].d1].y,dots[dists[i].d1].z,dots[dists[i].d2].x,dots[dists[i].d2].y,dots[dists[i].d2].z,dists[i].dis);
return 0;
}
| 64 |
31,692 | struct point{ //?????point?????
int x;
int y;
int z;
}pt[50];
struct data{ //?????data????????
int num;
struct point a; //?1
struct point b; //?2
double distance; //??
}dt[10000],temp;
int main(){
int n,i,j; //????n????i?j
cin>>n;
for(i=0;i<n;i++) //???????
{
cin>>pt[i].x;
cin>>pt[i].y;
cin>>pt[i].z;
}
int t=0; //??dt??
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
dt[t].num=t;
dt[t].a=pt[i];
dt[t].b=pt[j];
dt[t].distance=sqrt((pt[i].x-pt[j].x)*(pt[i].x-pt[j].x)+(pt[i].y-pt[j].y)*(pt[i].y-pt[j].y)+(pt[i].z-pt[j].z)*(pt[i].z-pt[j].z)); //????
t++;
}
int k; //??dt??
k=t;
for(i=0;i<k;i++) //??
for(j=i+1;j<k;j++)
{
if(dt[i].distance<dt[j].distance||(dt[i].distance==dt[j].distance&&dt[i].num>dt[j].num))
{
temp=dt[i];
dt[i]=dt[j];
dt[j]=temp;
}
}
for(i=0;i<k;i++) //??
{
cout<<"("<<dt[i].a.x<<","<<dt[i].a.y<<","<<dt[i].a.z<<")-("<<dt[i].b.x<<","<<dt[i].b.y<<","<<dt[i].b.z<<")=";
printf("%.2lf\n",dt[i].distance);
}
return 0;
}
| 64 |
31,693 |
struct zuobiao
{
int x ;
int y ;
int z ;
}s[10] ; //??xyz??????
double d[100] , temp ; //d??????????
int qian[100] , hou[100] , temp1 ; //qian hou ?????????????????????
int i , j , k = 0 ;
void dis(int , int) ;
void paixu() ;
int main()
{
int n ;
cin >> n ;
for (i = 0 ; i < n ; i++)
cin >> s[i].x >> s[i].y >> s[i].z ;
for (i = 0 ; i < n ; i++)
for (j = i + 1 ; j < n ; j++)
dis(i , j) ;
paixu() ;
for (i = 0 ; i < k ; i++)
{
cout << "(" << s[qian[i]].x << "," << s[qian[i]].y << "," << s[qian[i]].z << ")" << "-"
<< "(" << s[hou[i]].x << "," << s[hou[i]].y << "," << s[hou[i]].z << ")" << "=" ;
printf ("%.2f", d[i]) ;
cout << endl ;
}
return 0 ;
}
void dis(int a , int b)
{
int a1 , a2 , a3 ;
a1 = s[a].x - s[b].x ;
a2 = s[a].y - s[b].y ;
a3 = s[a].z - s[b].z ;
d[k] = sqrt(a1 * a1 + a2 * a2 + a3 * a3) ; //????
qian[k] = a ; //?k??????????
hou[k] = b ; //?k??????????
k++ ;
}
void paixu()
{
for (i = 0 ; i < k - 1 ; i++)
for (j = i + 1 ; j < k ; j++)
{
if (d[i] < d[j])
{
temp = d[i] ; //???????????qian hou????
d[i] = d[j] ;
d[j] = temp ;
temp1 = qian[i] ;
qian[i] = qian[j] ;
qian[j] = temp1 ;
temp1 = hou[i] ;
hou[i] = hou[j] ;
hou[j] = temp1 ;
}
else if (d[i] == d[j]) //???????qian hou??????????
if (qian[i] > qian[j] || (qian[i] == qian[j] && hou[i] > hou[j]))
{
temp = d[i] ;
d[i] = d[j] ;
d[j] = temp ;
temp1 = qian[i] ;
qian[i] = qian[j] ;
qian[j] = temp1 ;
temp1 = hou[i] ;
hou[i] = hou[j] ;
hou[j] = temp1 ;
}
}
} | 64 |
31,694 | /*
*???? 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 |
31,695 |
int main()
{
struct info1
{
int a[3];
}
point[N];
struct info2
{
int f[3],l[3];
double result;
}
dist[N*(N-1)/2];
int n,i,j,k=0,p;
double tmpdist;
int tmppoint;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d %d %d",&point[i].a[0],&point[i].a[1],&point[i].a[2]);
}
for (i=0;i<n;i++)
{
for (j=i+1;j<n;j++)
{
dist[k].result=sqrt((double)(point[i].a[0]-point[j].a[0])*(point[i].a[0]-point[j].a[0])+(point[i].a[1]-point[j].a[1])*(point[i].a[1]-point[j].a[1])+(point[i].a[2]-point[j].a[2])*(point[i].a[2]-point[j].a[2]));
for (p=0;p<3;p++)
{
dist[k].f[p]=point[i].a[p];
dist[k].l[p]=point[j].a[p];
}
k++;
}
}
for (j=1;j<k;j++)
{
for (i=0;i<k-j;i++)
{
if (dist[i].result<dist[i+1].result)
{
tmpdist=dist[i].result;
dist[i].result=dist[i+1].result;
dist[i+1].result=tmpdist;
for (p=0;p<3;p++)
{
tmppoint=dist[i].f[p];
dist[i].f[p]=dist[i+1].f[p];
dist[i+1].f[p]=tmppoint;
tmppoint=dist[i].l[p];
dist[i].l[p]=dist[i+1].l[p];
dist[i+1].l[p]=tmppoint;
}
}
}
}
for (i=0;i<k;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",dist[i].f[0],dist[i].f[1],dist[i].f[2],dist[i].l[0],dist[i].l[1],dist[i].l[2],dist[i].result);
}
return 0;
} | 64 |
31,696 | int main()
{
int n;
scanf("%d",&n);
int point[11][3];
for(int i=0;i<n;i++)
{
for(int j=0;j<3;j++)
{
scanf("%d",&point[i][j]);
}
}
double distance[15][15]={0};
double s;
for(int i=0;i<n;i++)
{
for(int k=1;i+k<n;k++)
{
s=sqrt((point[i][0]-point[i+k][0])*(point[i][0]-point[i+k][0])+(point[i][1]-point[i+k][1])*(point[i][1]-point[i+k][1])+(point[i][2]-point[i+k][2])*(point[i][2]-point[i+k][2]));
distance[i][i+k]=s;
}
}
double lenth[105];
int id[105][2];
int k=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(distance[i][j]==0)
{
continue;
}
id[k][0]=i;
id[k][1]=j;
lenth[k]=distance[i][j];
k++;
}
}
double e;
for(int p=1;p<k;p++)
{
for(int i=k-1;i>=p;i--)
{
if(lenth[i]>lenth[i-1])
{
e=id[i][0];
id[i][0]=id[i-1][0];
id[i-1][0]=e;
e=id[i][1];
id[i][1]=id[i-1][1];
id[i-1][1]=e;
e=lenth[i];
lenth[i]=lenth[i-1];
lenth[i-1]=e;
}
}
}
for(int i=0;i<k;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",point[id[i][0]][0],point[id[i][0]][1],point[id[i][0]][2],point[id[i][1]][0],point[id[i][1]][1],point[id[i][1]][2],lenth[i]);
}
scanf("%d",&n);
return 0;
} | 64 |
31,697 | int main()
{
int a[10][3],m,i,j,k=0,dis[100][2],b[100],temp,x,y,z;
double distance[100]={0};
scanf("%d",&m);
for(i=0;i<m;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=i+1;j<m;j++)
{
x=a[i][0]-a[j][0];
y=a[i][1]-a[j][1];
z=a[i][2]-a[j][2];
temp=pow(x,2)+pow(y,2)+pow(z,2);
distance[k]=sqrt(temp);
b[k]=k;
dis[k][0]=i;
dis[k][1]=j;
k++;
}
}
for(i=0;i<k;i++)
{
for(j=i+1;j<k;j++)
{
if(distance[b[i]]<distance[b[j]])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
else if(distance[b[i]]==distance[b[j]])
{
if(dis[b[i]][0]>dis[b[j]][0])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
else if(dis[b[i]][0]==dis[b[j]][0]&&dis[b[i]][1]>dis[b[j]][1])
{
temp=b[i];
b[i]=b[j];
b[j]=temp;
}
}
}
}
for(i=0;i<k;i++)
{
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",a[dis[b[i]][0]][0],a[dis[b[i]][0]][1],a[dis[b[i]][0]][2],a[dis[b[i]][1]][0],a[dis[b[i]][1]][1],a[dis[b[i]][1]][2],distance[b[i]]);
}
return 0;
} | 64 |
31,698 | int main(){
int N;
cin>>N;
int a[10][3];
int b[100][2];
int S=0;
float d[100];
for (int i=0;i<N;i++)cin>>a[i][0]>>a[i][1]>>a[i][2];
for (int i=0;i<N;i++){
for (int j=i;j<N;j++){
if (i==j)continue;
b[S][0]=i;b[S][1]=j;
d[S]=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]));
//cout<<d[S]<<endl;
S++;
}
}
int t;
float ft;
for (int i=0;i<S;i++){
for (int j=S-1;j>i;j--){
if (d[j]>d[j-1]){
ft=d[j];d[j]=d[j-1];d[j-1]=ft;
t=b[j][0];b[j][0]=b[j-1][0];b[j-1][0]=t;
t=b[j][1];b[j][1]=b[j-1][1];b[j-1][1]=t;
}
}
}
cout<<fixed;
for (int i=0;i<S;i++){
cout<<"("<<a[b[i][0]][0]<<","<<a[b[i][0]][1]<<","<<a[b[i][0]][2]<<")-("<<a[b[i][1]][0]<<","<<a[b[i][1]][1]<<","<<a[b[i][1]][2]<<")="<<setprecision(2)<<d[i]<<endl;
}
cin>>N;
return 0;
}
| 64 |
31,699 | double distance(int b1[],int b2[])
{
int X,Y,Z;
double D;
X=(b1[0]-b2[0])*(b1[0]-b2[0]);
Y=(b1[1]-b2[1])*(b1[1]-b2[1]);
Z=(b1[2]-b2[2])*(b1[2]-b2[2]);
D=sqrt(X+Y+Z);
return D;
}
int main()
{
int n,i,j,r=0,p,k=0;
int a[30],b[10][3];
double d[100][3],temp;
scanf("%d",&n);
for(i=0;i<3*n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
b[i][0]=a[3*i];
b[i][1]=a[3*i+1];
b[i][2]=a[3*i+2];
}
for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
{
d[k][0]=distance(b[i],b[j]);
d[k][1]=i;
d[k][2]=j;
k++;
}
for(i=1;i<k;i++)
for(j=0;j<k-i;j++)
if(d[j][0]<d[j+1][0])
{
temp=d[j][0];
d[j][0]=d[j+1][0];
d[j+1][0]=temp;
temp=d[j][1];
d[j][1]=d[j+1][1];
d[j+1][1]=temp;
temp=d[j][2];
d[j][2]=d[j+1][2];
d[j+1][2]=temp;
}
for(p=0;p<k;p++)
{
i=d[p][1];
j=d[p][2];
printf("(%d,%d,%d)-(%d,%d,%d)=%.2lf\n",b[i][0],b[i][1],b[i][2],b[j][0],b[j][1],b[j][2],d[p][0]);
}
return 0;
}
| 64 |
Subsets and Splits