Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
|
|
@ -0,0 +1,32 @@
|
|||
10 'SAVE "INSERTGW",A
|
||||
20 DEFINT A-Z
|
||||
30 OPTION BASE 1
|
||||
40 N=20: R=100: I=0: Y=0: V=0: P=0
|
||||
50 DIM A(N)
|
||||
60 ' Creates the disordered array
|
||||
70 CLS: PRINT "This program sorts by Insertion a list of randomly generated numbers."
|
||||
80 PRINT: PRINT "Unsorted list:"
|
||||
90 RANDOMIZE TIMER
|
||||
100 FOR I = 1 TO N
|
||||
110 A(I) = INT(RND * R) + 1
|
||||
120 NEXT I
|
||||
130 GOSUB 260
|
||||
140 PRINT: PRINT "Sorted list."
|
||||
150 ' Insertion Sort
|
||||
160 FOR I=1 TO N
|
||||
170 V=A(I): P=I-1: S=1
|
||||
180 WHILE P>0 AND S=1
|
||||
185 S=0
|
||||
190 IF A(P) > V THEN A(P+1)=A(P): P=P-1: S=1
|
||||
200 WEND
|
||||
210 A(P+1) = V
|
||||
220 NEXT I
|
||||
230 GOSUB 260
|
||||
240 PRINT: PRINT "End of program execution."
|
||||
250 END
|
||||
260 ' Print list routine
|
||||
270 FOR I=1 TO N
|
||||
280 PRINT A(I);
|
||||
290 NEXT I
|
||||
300 PRINT
|
||||
310 RETURN
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
100 PROGRAM "InserSrt.bas"
|
||||
100 PROGRAM "InserSrt.bas"
|
||||
110 RANDOMIZE
|
||||
120 NUMERIC ARRAY(5 TO 21)
|
||||
130 CALL INIT(ARRAY)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue