# Untitled

unknown

plain_text

22 days ago

1.6 kB

0

Indexable

Never

^{}

/* What the assignment is asking: -get points (the number of points the user will input is gonna be n numbers) -each point will have an x, y, and label (R or B) -get one specific point (we'll call it classsified point) to compare to the rest -find distance between rest of points and the classified point (using euclidean algorithm) -find the k (another user input) number of closest points to the classified point -count the labels of the closest points (are there more close points with R or B label?) -if there are more R than B, print out R, else print B */ //Functions to make: // make function to calculate Euclidean distance between two points (x1, y1) and (x2, y2) //distance (euclidean algorithm) = sqrt(pow((x2 - x1),2) + pow((y2 - y1), 2)); // make a struct to define a point with x, y coordinates and a label //make function to sort the array of points and the array of distances //you can use any sort algorithm for this ^ //function to count the labels (After the arrays are sorted) //main function //declare int n and k (n is number of points) (k is num of points to compare to classified point) //std cin these ^ //for loop to collect points (it should run through n length) //declare array or vector to collect points //declare classified point (an x and a y) //std cin these ^ //declare array to put the distances //for loop to calculate distances //(use the euclidean algorithm function that I mentioned above) //call sort function //call label count function

Leave a Comment