×

# Retrieving y co-ordinates

 0 Hi friends, I recently came up with a question. Kindly tell me it's solution. My question: There are n points with co-ordinates (x1,y1), (x2,y2),........, (xn,yn). I want to sort these points based on the value of their x co-ordinates. Therefore I am using the sort function to sort the x co-ordinates, but am unable to access there respective y co-ordinates. Please tell me a way by which I can retrieve the corresponding y co-ordinates after sorting with the best efficiency. Thanks in advance asked 26 Jan '15, 10:03 378●5●25 accept rate: 7%

 0 sort using struct,bool func.  struct vert { int xcord,ycord; }; bool cmp (vert a,vert b) //two objects a&b of type vert(struct) { return a.xcord...Didn't I explain it to you a billion times in school!?!?! And HOW DO YOU carry out AN !?Answer?! and get the "DESIRED" !?Answer?!...LOL (CaRrY oUt???) I am the one who liked ur SILLY comment and am very sure that I'll remain to ONLY one to do so...HA HA HA!!! (26 Jan '15, 23:55) arpanb83★ i bet u r solving RECTANGLES.. (27 Jan '15, 00:02) arpanb83★ OOOOOOOOOOOOOOOOOOOOOO...u got another like?!?!?!?! (28 Jan '15, 15:09) arpanb83★ @arpanb8 Therefore aren't you SILLY enough to consider my comment SILLY?!?!?!?!?! (29 Jan '15, 21:34) i mean 2 is the upper bound for numberOfLikes. numberOfLikes<=2... (29 Jan '15, 23:39) arpanb83★ showing 5 of 6 show all
 0 You can also use a vector of pairs. Try running the below code to understand how. Personally, I am biased towards this method of sorting as I've never used structs before :P answered 26 Jan '15, 14:52 3★sandy999 391●1●15●37 accept rate: 10% 1 Or an array of pairs. (26 Jan '15, 15:02) superty3★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×691
×1
×1

question asked: 26 Jan '15, 10:03

question was seen: 905 times

last updated: 29 Jan '15, 23:39