In this project you are asked to find K nearest neighbors of all points on a 2D space. The distance
metric that you are going to use is simply the Euclidean distance
example;
Please note, that this is not a homework site. We won't do your homework for you. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.
We didn't see your attemts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find deriviative of function without knowledge in ariphmetics, you cannot do more complex tasks in programming without clear understanding of basics
i never asked to give the whole code but an idea and opinion
You just dumped assigment without asking question.
Now for your program structure:
1) Create a structure to hold a point (2 coordinates) or use std::pair
2) Create a vector of your points
3) Read input in said vector.
4) For each point: sort vector by distance from said point.
5) Output K points starting from index [1] (in [0] there will be original point)
1) your vector is called points, not point
2) You cannot assign points like that. Remember, vector can be threated as resizeable array. Use push_back() or initialization lists:
That depends on what your inputs mean. What does everything here mean? 10 2
3.57 3.18
84.91 27.69
93.40 4.62
67.87 9.71
75.77 82.35
74.31 69.48
39.22 31.71
65.55 95.02
17.12 3.44
70.60 43.87