Bubble Sort - Accending and Deccending Order ?
Posted on 2000-04-13
I need some help on figuring out how to use a bubble sort method, to arrange all the numbers that a user enters in for (Number[x]) , in accending and deccending order.
Any help would be greatly appreciated.
Uses CRT, dos;
Var Number: array [1..5] of integer;
Arr: array [1..100] of integer;
numtotal:= 0 ;
write('How many numbers (maximum = 100)? ') ;
If numbers > 100 then
writeln('ERROR - Please enter a number between 1 and 100') ;
If numbers < 1 then
writeln('ERROR - Please enter a number between 1 and 100' );
If numbers < 101 then
If numbers > 0 then
Until numtotal = 5 ;
For x:= 1 to numbers do
write('Enter # ' , x , ' : ' ) ;
I need some kind of bubble sort code in here, to arrange the numbers I entered for Number[x] in accending and deccending order.
Write ('Would you like to enter more numbers (Y/N)? ') ;
Until ans = 'N' ;