1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
| dim rando,80
randomize
repeat length(rando)
rando(cnt) = rnd(length(rando))
loop
notesel buf2
repeat length(rando)
noteadd "rando("+cnt+") = "+rando(cnt),-1
loop
i=0
repeat length(rando)-1,1
i=cnt
postion=0
tmp=rando(i)
repeat i
if rando(i-cnt-1)<tmp : postion=i-cnt : break
loop
repeat i-postion
rando(i-cnt)=rando(i-cnt-1)
loop
rando(postion)=tmp
loop
notesel buf
repeat length(rando)
noteadd "rando("+cnt+") = "+rando(cnt),-1
loop
title "挿入ソートの例"
objmode 1
sysfont 17
pos 2, 4 : mes "ソート前"
pos 312, 4 : mes "ソート後"
pos 0,20 : mesbox buf2,300,300,0
pos 310,20 : mesbox buf,300,300,0
stop
|