Help with Arrays
Author |
Message |
lordoftheflies
|
Posted: Tue May 16, 2006 1:27 pm Post subject: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheOneTrueGod
|
Posted: Tue May 16, 2006 1:59 pm Post subject: (No subject) |
|
|
In order to output them in order, you need to sort them so they are in order... makes sense, right?
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
|
|
|
|
|
|
|