I have several elements in a vector type that are read from cin and then i perfrom some calculations on the vector and it's order of elements gets changed. The problem is that I need to print the positions of the vector elements after the calculations. I don't know how to explain this well that's why i'll give an example:
10 1 100 1000
and 10 is 1st element, 1 is 2nd, 100 is 3rd etc. After the calculations the vector changes in :
100 10 1 1000
so I should print
3 1 2 4
because 100 is the 3rd element of the input, 10 is the 1st etc. etc.
I tried with an array[1000] (because there aren't numbers larger than 1000 in the input), but it won't work because there can be multiple numbers with the same value, like:
10 10 10 100
and the output can be 1 2 3 4
or 2 3 1 4
or 3 1 2 4
etc. but here i need to output 1 2 3 4
because it's the 'smallest'.
I tried with array f[1001]
and f[10] = 1
, f[100] = 2
, f[1] = 3
- if the numbers from the input are 10 100 1
. But in case there are multiple numbers with the same value like 10 10 100
, then my idea's not working. Please help me in any possible way.