954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Finding Positon of characters

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.

Awais Ahmad
Newbie Poster
5 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

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?

I will not just solve your problem. I will help YOU solve your problem.

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?

Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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?

mrboolf
Junior Poster
183 posts since Jun 2008
Reputation Points: 134
Solved Threads: 18
 

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)

Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You