Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
#include <iostream> #include <fstream> using namespace std; int main() { ifstream fin("hwdata.txt"); int n; fin >> n; double **D = new double*[n]; for(int i = 0; i < n; i++) D[i] = new double[2]; // index 0 is x-coord, index 1 is y-coord for(int i = 0; i < n; i++) fin >> D[i][0] >> D[i][1]; double* w = new double[2]; cin >> w[0] >> w[1]; int k = search(D,n,w); if (k == n) cout << "No point found!" << endl; else cout << "Point: (" << D[k][0] << ',' << D[k][1] << ')' << endl; }
k
provided that the point
described by array
element D[k]
was within distance .01 of the point defined
by w
.
int
s
from the
user and prints them into order so that all the odd numbers come
first (in increasing size) followed by all the even numbers
(in increasing size). For example:
~/$ ./hw
18 2 7 14 29 3 5 8 16 11
3 5 7 11 29 2 8 14 16 18
It is expected that you use selection sort (as described in
the notes), and there is a "good" way to do this, and an
"ugly hack" way to do it. Try to do it the good way!