I want to writer a program in which i input an array?
let the array i entered is :
4
1
2
3

The prigram can take values and find the positions of the character in the array such that the smallest on 0 position and so on.
The result of the array will be if i start array from 0

1
2
3
0

that means it will find the position of the numbers in the array and display it on the screen
Onlt the position of the numbers is specifying and the position of the numbers.

Any one to solve it.

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Murtan

If the array entered was:

``````40
20
10
30``````

I think the output should be:

``````2
1
3
0``````

Does it look like I understood the what the program is supposed to do?

If you're writing a program, it will need to do the following:
1) Accept the user input for the array
2) Generate the output array
3) Display the output array

Have you written anything yet?

If so, which parts have you addressed?

I don't get it. How do you go from "40 20 ..." to "2 1 3 0" ?

I think that the resulting array is the list of positions that the elements of the first array occupied before being sorted.
For example the min elements of the first array is 10 and it was in position 2, then we have 20 at position 1, 30 at position 3 and 40 at position 0, so (40, 20, 10, 30) -> (0, 1, 2, 3) and (10, 20, 30, 40) -> (2, 1, 3, 0)

Someone please correct me if I'm wrong.

EDIT: I didn't see the other thread - why do some people think so often that quantity necessarily means quality?

I was trying to understand what he wanted to accomplish so I restated the problem. It did appear to me that the output array was an index into the the original array, but I wanted the original poster to confirm my understanding.

(If there's another thread, I didn't see it either -- sigh)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.