Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include const int MAX = 1000; const char CLASS[] = {'A','B','C'}; struct Points{ int x,y; char c; double dist(Points q){ return sqrt(pow(x-q.x,2)+pow(y-q.y,2)); }

image text in transcribed

#include

#include

#include

const int MAX = 1000;

const char CLASS[] = {'A','B','C'};

struct Points{

int x,y;

char c;

double dist(Points q){

return sqrt(pow(x-q.x,2)+pow(y-q.y,2));

}

};

int main(){

return 0;

}

int main(){

srand(time(0));

}

Lab 6 Use the lab5.cpp as a started file. Modify the program is it generates 1000 points with a random x and y being values between 0 and 10000 and random c being either an 'A', 'B' or ' C '. Your program should ask for a point from the user and your program should assign a c value to that point based on the 5 closest points to it. The c value will be equal the to the most common c value of the 5 closest points. (in the case of a tie it should become an A if A and B tie, a B if B and C tie and an A is A and C tie). It should print out the 5 nearest points and the c value of the input point. Enter X and Y00 (14,9) is class A and the distant is 16.6433 (9,52) is class B and the distant is 52.7731 (17,52) is class A and the distant is 54.7083 (57,4) is class B and the distant is 57.1402 (36,46) is class B and the distant is 58.4123 (0,0) is class B

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

Generate a custom Nios II processor core,

Answered: 1 week ago

Question

State the major weakness of H . 3 2 3 Compared to SIP [ 3 ]

Answered: 1 week ago

Question

Over what timescale should the project be undertaken?

Answered: 1 week ago