1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
#include <iostream> #include <iomanip> #include <cmath> #include <ctime> #include <cstdlib> using namespace std; struct Point { double x, y; }; double getDistance(struct Point a, struct Point b); double random(unsigned long int & seed); int main() { unsigned long int seed; srand(time(NULL)); seed = rand(); const int SIZE=50; Point array[50]; for(int i=0; i<SIZE; i++) { array[i].x = -5+(10*random(seed)); array[i].y = -5+(10*random(seed)); cout << array[i].x << endl;; cout << array[i].y << endl; } cout <<" Max Distance between a and b: %lf\n"<< endl ; return 0; } double random(unsigned long int & seed) { const int MODULUS = 15749; const int MULTIPLIER = 69069; const int INCREMENT = 1; seed = ((MULTIPLIER*seed)+INCREMENT)%MODULUS; return double (seed)/MODULUS; } double getDistance(struct Point array ) // help needed { double distance; return distance; }
1234567891011121314
double getDistance(Point array[], int size) // help needed { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { double dx = array[i].x - array[j].x; double dy = array[i].y - array[j].y; // etc. double distance = std::sqrt(dx * dx + dy * dy); } } return 0.0; // todo }
double distance = getDistance(array, SIZE);
double getDistance(struct Point a, struct Point b);
12345
double getDistance(struct Point array ) // help needed { double distance; return distance;
for (int j = i+1; j < size; j++)