![]() |
| ||
| Ordering arrays? Hi, i am given an array of atomic numbers, and I need to arrange them in order from 1-100 or something. the program i wrote is this for(fill = 0; fill < (m-1); ++fill)gives these the output below. It only orders 88 in the right order. How should I order all the elements in the right order. the array of elements 1 1 1 50 84 88 1 1 1 1 1 1 11 20 84 ordering only 88. 1 1 1 50 84 1 1 1 1 1 1 11 20 84 88 how should i make them order 1,1, 1, 1, 11, 20, 84, 84, 88 something like this? thanks, |
| ||
| Re: Ordering arrays? You can using qsort() function which is come with <stdlib.h> header. Here the example of how to use this function: #include <stdio.h> |
| ||
| Re: Ordering arrays? Quote:
For that you need two index variables and two loops.
|
| ||
| Re: Ordering arrays? yeah it works, but I also need to printf the name of the element and the symbol along with atomic numbers. How would I do that? Would i use sturctures or parallel array and switch indexes or somethings? I don't know how I would go about it? |
| ||
| Re: Ordering arrays? You could use a struct, or if the idea is too abstract for you, toy with the idea of parallel arrays, like you said. |
| All times are GMT -4. The time now is 9:14 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC