Initialize two arrays that specify n points with coordinates (X, Y) in two-dimensional space. Describe the function that finds the distance between two arbitrary points.
At start, the following code gives out -80, then 112, then 160. Please help me, please, what is the error?
#include "stdafx.h" #include "iostream" #include <math.h> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int *x=new int [5] {1, 4, 6, 2, 1}; //ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈΠ· 5 ΠΊ-Ρ Ρ
int *y=new int [5] {6, 7, 8, 9, 10}; //ΡΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΌΠ°ΡΡΠΈΠ²Π° ΠΈΠ· 5 ΠΊ-Ρ Ρ cout << "Π Π°ΡΡΡΠΎΡΠ½ΠΈΠ΅ ΠΌΠ΅ΠΆΠ΄Ρ Π΄Π²ΡΠΌΡ ΡΠΎΡΠΊΠ°ΠΌΠΈ:" << distance(x,y) << endl; } int distance(int *x,int* y, int size) // { float d; d = sqrt(pow((x[1] - x[0]), 2) + pow((y[1] - y[0]), 2)); return d; }
using namespace std;... - AnTusing namespace std;for some purpose. Which one - AnT