#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
using namespace std;
int dis;
int main()
{
ifstream infile("zuobiao.txt");
int x,y;
vector<int> b;
vector<int> c;
while(!infile.eof())
{
infile>>x>>y;
b.push_back(x);
c.push_back(y);
}
cout<<b.size()<<endl;
//int b[]={0, 649, 971, 164, 773, 747, 260, 163, 576, 765, 397, 586, 963, 414, 441, 247, 637, 956, 384, 414, 414};
//int c[]={0, 766, 81, 681, 419, 890, 50, 188, 681, 37, 20, 713, 567, 458, 935, 115, 132, 967, 364, 458, 458};
ofstream outfile("distance.txt");
//ofstream outfile("distance.txt");
for(int i=0;i<b.size();i++)
{
for(int j=0;j<b.size();j++)
{
dis=sqrt((b[i]-b[j])*(b[i]-b[j])+(c[i]-c[j])*(c[i]-c[j]));
//dis=abs(b[i]-b[j])+abs(c[i]-c[j]);
// if(i!=j && dis==0)
// {
// outfile<<0.001<<" ";
// }
// else
// {
outfile<<dis<<" ";
// }
}
outfile<<endl;
}
return 0;
}
读入坐标文件输出坐标距离
最新推荐文章于 2022-11-19 15:50:49 发布