I have the coordinates of n points and I need to calculate the distance between each point until the other points.
2 0
3 0
0 5
2 1
...
...
...
I am beginner in C + + and I've worked a lot before asking for help.
Already, I thank you for the help.
#include <iostream>
#include <fstream>
# include <stdio.h>
# include <cmath>
#define N 4
#define M 2
using namespace std;
int main()
{
int i,j,k;
double **a;
a=new double *[N+1];
for (i=0;i<=N;i++)
a[i]=new double [N+1];
ifstream inputfile;
inputfile.open("file.in");
if(inputfile.fail())
{
cout<<"The file could not be opened!\n";
}
//row operations
double m;
for (j=0;j<=1;j++)
for (i=0;i<=N-1;i++)
for (k=i+1;k<=N-1;k++)
{
m[i][j]=sqrt(pow((a[k][1]-a[i][1]),2)-(pow((a[k][2]-a[i][2]),2)));
m += a[i][j];
cin >> i,j,a[i][j];
}
for (i=1;i<=N;i++)
{
for (j=1;j<=N;j++)
cout << a[i][j] << " ";
cout << endl;
}
cout << endl;
return 0;
}