[tt]
#include "AnArray.h"
#include <iostream.h>
int main()
{
CAnArray CPointS;
CPoint pt, spt;
srand( (unsigned)time( NULL ) );
for(int i = 0; i < 20; i++)
{
pt.x = rand()%100;
pt.y = rand()%100;
CPointS.Add(pt);
cout << "(" << pt.x << "," << pt.y << "
" << endl;
}
cout << "Enter an x coordinate: ";
cin >> spt.x;
cout << "Enter a y coordinate: ";
cin >> spt.y;
[/tt]
This is what I have so far. How do I sort through the array to find the closest random CPoint object to the CPoint object the user enters? Could you include comments so I could understand I really want to learn this stuff
. Thanks for you time guys!
-CDudd
#include "AnArray.h"
#include <iostream.h>
int main()
{
CAnArray CPointS;
CPoint pt, spt;
srand( (unsigned)time( NULL ) );
for(int i = 0; i < 20; i++)
{
pt.x = rand()%100;
pt.y = rand()%100;
CPointS.Add(pt);
cout << "(" << pt.x << "," << pt.y << "
}
cout << "Enter an x coordinate: ";
cin >> spt.x;
cout << "Enter a y coordinate: ";
cin >> spt.y;
[/tt]
This is what I have so far. How do I sort through the array to find the closest random CPoint object to the CPoint object the user enters? Could you include comments so I could understand I really want to learn this stuff
-CDudd