Answered step by step
Verified Expert Solution
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)); }
#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
#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));
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started