Sorting algorithms/Insertion sort: Difference between revisions

No edit summary
Line 354:
=={{header|Commodore BASIC}}==
<lang basic>
10 dimaDIM A(10):n N=9
11 REM GENERATE SOME RANDOM NUMBERS AND PRINT THEM
11 rem generate some random numbers and print them
12 foriFOR I=0ton0 TO N:a A(iI)=intINT(rndRND(1)*10)+1:next NEXT:gosub50 GOSUB 50
20 forjFOR J=1ton1 TO N:keyKEY=aA(jJ):i I=jJ-1:gosub30 GOSUB 30:a A(iI+1)=keyKEY:next NEXT:gosub50 GOSUB 50:end END
30 ifiIFI=-1 thenTHEN returnRETURN
31 ifaIFA(iI)>keyKEY thenTHEN aA(iI+1)=aA(iI):iI=iI-1:goto30 GOTO 30
32 returnRETURN
50 printPRINT:fori FOR I=0ton0 TO N:printa PRINTA(iI):next NEXT:return RETURN
</lang>
 
Anonymous user