Rearrangement Of Data (Sorting) - Casio FX-730P Owner's Manual

Table of Contents

Advertisement

88
5-1 Rearrangement of Data (Sorting}
Sorting of disorderly data often becomes important in the creation of practical
programs. Here we will introduce a program using a method called "bubble
sort".
Consider a program to display the ranking of eight examinees from No. 101 to
108 by sorting their points supplied.
• Program List
10 REM
bubble sort
20 H4PIJT
"t·it...jmber
i::of
d .::t
.
tJ.:oo.", C
30
~H1
DI MEt-6 I OM
40 DIM 0(3,C)
50 REM
da.t.:;..
set.
60 FOR A=1 TO C
70 READ
C• (
1, A) , D ( 2, A)
:30 NE:,,:T A
90 PRHff
"si:1rtJin9";
100 REM
sortJ
110 FOR A=1 TO C-1
120 FOR B=A+l
TO
C
130 IF
0(2,A)~0(2,8)
THEM 160
140 D=D(1,A):D(1,A)=D(1,8):0(1,B>=D
150 D=D(2,A):D(2,A)=0(2,8):0(2,8)=D
160 NE>ff B
170 r4E:=<T A
1:30 FOR A=l TO C:D(3,A>=A: NE:=<T A
190 FOR A=l TO C-1
200 IF 0(2,A))0(2,A+1) THEM 220
210
D(
3,A+1)=0(3,A)
220 NEXT A
300 REM
1:::i1..1tp1...1tJ
310 FOR A=l TO C
320 BEEP : PRIMT
330 PRINT 0(3,A); CSR5; "r4o";D(1,A);
cs
R15; ".;."; 0(2, A)
340 NEXT A
350 PRINT "OlJER"

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents