473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Finding Posistion of array elements

I want to write a program which take input and save the poistions of the array elements in another array.
let if i enter an array
A[0]= 4
A[1]=1
A[2]=2
A[3]=3
now the output array will hold
1
2
3
0
i-e the posistions of the array elements starting from the smallest number.
As 1 is the smallest number and it is on 1 posistion the output array will hold values like this
B[0]=1 //Posistion of the smallest number
B[1]=2 //Posistion of second smallest number
B[2]=3 //and so on
B[3]=0 //as 4 is on 0 posistion so it will be on this location of out //array.
This program can find the posistion of the numbers in an array.
It will put that posistions in another array in such a way that posistion of smallest number in first posistion of outpur array and soon.

This is the problem any one to solve it.
Dec 2 '08 #1
2 1837
vmpstr
63
You can solve it in a fairly straight forward manner, how much have you done already?

You can either just search A and put an appropriate value in B, or you can use A as an index into B (the latter will only work if you have numbers from 1 to n, not any arbitrary numbers).
Dec 2 '08 #2
hsn
237 100+
as vmpstr said.
when u find your value print its index.
pretty straight forward.

hsn
Dec 2 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
3
by: trevorelbourne | last post by:
Hi, I am having trouble accessing the elements of an array using reflection. This is the code I am having trouble with: FieldInfo Fields = Obj.GetType().GetFields(); foreach (FieldInfo fi in...
8
by: ljlevend2 | last post by:
If a property's type is an array and the property is exposed in a PropertyGrid, then the property can be expanded so that the user can view and edit the array elements. But, I've noticed that if...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
6
by: Kumar | last post by:
How should I declare the array elements being half word? and the array elements of the type byte in C?? Please help Kumar
8
by: SP | last post by:
The following code crashes after I add the two nested FOR loops at the end, I am starting to learn about pointers and would like to understand what I'm doing wrong. I think the problem is the way...
14
by: dan | last post by:
I would like to have the preprocessor automatically generate the number of array elements requested. Each element is zero. The elements get pasted into a larger array. The other elements may be...
1
by: simply123 | last post by:
I doing doing C btw... i have been trying to convert array elements into their respective addresses but Im faced with many problems. eg. int x (array with 7 elements) im trying to set the...
1
by: eran yurman | last post by:
H, I need to call an API with the follwoing prototype: unsigned long CountDevices (BYTE *p_deviceSize,BYTE *p_device ); I have no knowledge of the content of the API function itself but...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.