DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Finding Positon of characters (http://www.daniweb.com/forums/thread160424.html)

Awais Ahmad Dec 2nd, 2008 11:02 am
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.

Murtan Dec 2nd, 2008 11:22 am
Re: Finding Positon of characters
 
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?

Ancient Dragon Dec 2nd, 2008 12:34 pm
Re: Finding Positon of characters
 
I don't get it. How do you go from "40 20 ..." to "2 1 3 0" ?

mrboolf Dec 2nd, 2008 1:17 pm
Re: Finding Positon of characters
 
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?

Murtan Dec 3rd, 2008 12:17 am
Re: Finding Positon of characters
 
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)


All times are GMT -4. The time now is 10:31 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC