# POJ 3702 距离排序

….(n-1,n)

#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
using namespace std;

#define maxp 12

struct points{
int x,y,z;
};

typedef struct{
points p1,p2;
double val;
}Dis_t;

bool operator <(Dis_t a, Dis_t b){
return a.val < b.val;
}

ostream & operator<<(ostream &output,Dis_t src){
//(0,0,0)-(1,1,1)=1.73
cout<<"("<<src.p1.x<<","<<src.p1.y<<","<<src.p1.z<<")-(";
cout<<src.p2.x<<","<<src.p2.y<<","<<src.p2.z<<")=";
cout<<fixed<<setprecision(2)<<src.val;
}

points point[maxp]={0};
Dis_t dis[maxp*maxp]={0};
int n;
int discount = 0;

double calcu(int i,int j){
double dis0;
double dx = point[i].x - point[j].x;
double dy = point[i].y - point[j].y;
double dz = point[i].z - point[j].z;
dis0 = sqrt(dx*dx+dy*dy+dz*dz);
//cout<<dis0<<endl;
return dis0;
}

int main(){
cin>>n;
for(int i=0;i<n;++i){
cin>>point[i].x>>point[i].y>>point[i].z;
}

for(int i=0;i<n-1;++i){
for(int j=i+1;j<n;++j){
Dis_t tmp;
tmp.p1 = point[i];
tmp.p2 = point[j];
tmp.val = calcu(i,j);
dis[discount++] = tmp;
}
}

//sort(dis,dis+discount);
for(int i=0;i<discount-1;++i){
for(int j =0;j<discount-i-1;++j){
if(dis[j]<dis[j+1]){
Dis_t t = dis[j];
dis[j] = dis[j+1];
dis[j+1] = t;
}
}
}

for(int i=0;i<discount;++i){
cout<<dis[i]<<endl;
}
//system("pause");
return 0;
}


#### POJ 3214 Object Clustering 哈夫曼距离最小生成树

2016-08-13 16:54:38

#### poj1328 Radar Installation 贪心 （手动翻译）

2016-01-25 11:03:44

#### openjudge 距离排序

2014-03-26 17:44:31

#### Microsoft SQL Server，错误: 3702

2017-03-18 15:50:51

#### 无法删除数据库::提示:错误3702!无法除去数据库"test",因为它正在使用!!!

2007-01-04 19:48:00

#### POJ 上几个关于排列的题目

2015-05-10 20:00:25

#### POJ2388-排序水题

2016-09-08 11:19:30

#### POJ - 3241 Object Clustering 哈夫曼距离最小生成树

2017-06-13 18:06:57

#### cxf之HelloWorld版本实例

2014-01-28 21:39:22

#### DNA排序 代码

2013年11月28日 1KB 下载