
-----------------------------------
lordoftheflies
Tue May 16, 2006 1:27 pm

Help with Arrays
-----------------------------------
I have this problem with arrays. I've gotten the first part, where I can input numbers and it outputs the same set, and I've even figured out how to make the smallest number in the set of numbers. But I need it to display the numbers in order, from least to greatest.

var number : array 1 .. 10 of int
var small : int

put "Input number"
for i : 1 .. 10
    get number (i)
end for

small := number (1)

put "Smallest number"
for i : 2 .. 10
    if small > number (i) then
        small := number (i)
    end if
end for
put small


that's what I have so far... thanks

-----------------------------------
TheOneTrueGod
Tue May 16, 2006 1:59 pm


-----------------------------------
In order to output them in order, you need to sort them so they are in order... makes sense, right?  :wink: 

There is a bubble sort procedure here:
http://www.compsci.ca/v2/viewtopic.php?t=12268
but DON'T COPY IT DIRECTLY
doing so is plagarism, and is subject to things as severe as expulsion in some schools.  Instead, read the code, and learn from it.  Create your own procedure that will do the same thing using the concept.  Once you learn this, it is an easy matter to create your own.

Good luck.

-----------------------------------
Cervantes
Tue May 16, 2006 5:53 pm


-----------------------------------
Another good post to refer to: Quicksort
http://upload.wikimedia.org/wikipedia/en/4/4a/Quicksort_example_small.png
