EvilZone

Programming and Scripting => C - C++ => : Drahgon December 22, 2015, 12:10:38 AM

: Need to store an array number with its respective value
: Drahgon December 22, 2015, 12:10:38 AM
Problem:

(https://gyazo.com/80c7b9f6016ac8b452e18718f1791bd9)

I can order the numbers .. however I can't seem to find a way to output the ordered values with their respective values in the array that they are originally stored.

Seems almost impossible to me unless there is an inbuilt function that allows you to do it.
: Re: Need to store an array number with its respective value
: zombie December 22, 2015, 01:15:56 AM
Can you please elaborate more on what your problem is? I don't quiet understand what you are asking.

From what I can tell, it seems like you are asking us to sort an array and then print out the corresponding indices that they were in the unsorted array. Is that correct?

Also, the image you posted is improperly constructed.
: Re: Need to store an array number with its respective value
: Drahgon December 22, 2015, 03:05:33 AM
Can you please elaborate more on what your problem is? I don't quiet understand what you are asking.

From what I can tell, it seems like you are asking us to sort an array and then print out the corresponding indices that they were in the unsorted array. Is that correct?

Also, the image you posted is improperly constructed.

Sorry, yes that is what I mean :) I have sorted the array correctly but I need to attach the value of {i} that the number was originally stored in. So for example if you have 10 numbers, the 4th number was 6 and so was the 3rd largest .. and the 7th was 5 an and so was the 4th largest .. I would want to output Person 4: 6 .. Person 7: 5 etc
: Re: Need to store an array number with its respective value
: Kurajber December 22, 2015, 03:11:18 AM
You can make another array with indexes, and when you switch the values of your first array when sorting, switch the values of that other array also.
: Re: Need to store an array number with its respective value
: Drahgon December 22, 2015, 03:51:02 AM
You can make another array with indexes, and when you switch the values of your first array when sorting, switch the values of that other array also.
Cool thanks i'll give that a go :)