list

Hi, I need to write three functions, first one that need to extract Largest on the list, second one is split the Big and Small number. and the third one is split the even and odd number of list. Can any body give me some suggestions or example that show me how can i get that done.
start simple:
1. build a list of integers:
int intList[10] = { 0, 8, 4, -12, 1234, 54, 1, 8, 91, 100 };

2. try to do a simple sort routine on the array:
1
2
3
4
5
6
7
8
9
10
11
12
13
    for(int i = 0; i < array_size; ++i)
    {
        for(int j = 0; j < (array_size - 1); ++j)
        {
            if(list[j] > list[j+1])
            {
                 //swap the two elements, 
                 //0 <-> 8 no swap, 8<->4 swap etc.
                 //thus, your larger number will bubble to the biggest array index
            }
        }
     }
     std::cout <<  "Largest is: " << intList[9];


3. of course, now that your array is neatly sorted it's easy to split it!

4. then you can adapt 2 & 3 for sorting the odds and evens ;)

n.b I make no promise of these being the most effective algorithm, or the most elegant solution one can find >:)
Topic archived. No new replies allowed.