1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include<iostream>
#include"fstream"
#include <math.h>
using namespace std;
int main()
{double xm1,ym1,xc1,yc1,xm2,ym2,xc2,yc2,min[163],a,xc,yc;
ifstream input1("file.dat");
ifstream input2("file.dat");
ofstream output("error.dat");
for(int i=0;i<163;i++)
{input1>>xm1>>ym1>>xc1>>yc1;
min[i]=pow(((pow(ym1-yc1,2)/4)+(pow(xm1-xc1,2)/4)),0.5);
while (!input2.eof()){ input2>>xm2>>ym2>>xc2>>yc2;
a=pow(((pow(ym1-yc2,2)/4)+(pow(xm1-xc2,2)/4)),0.5);
if (a<min[i]) min[i]=a,xc=xc2,yc=yc2;
}
output<<xm1<<" "<<ym1<<" "<<xc<<" "<<yc<<" "<<min[i]<<endl;
input2.close();
}
}
|