home *** CD-ROM | disk | FTP | other *** search
- randomize
- print "Reverse (0 to Quit)"
- DIM A(20)
- N = 9
- 10 print "Working...";:y=pos(0):x=csrlin
- A(1)=rand(n)+1
- FOR K=2 TO N
- locate x,y:print k;
- 45 f = 0
- A(K)=rand(n)+1
- FOR J=1 TO K-1
- IF A(K)=A(J) THEN f = 1
- NEXT j
- if f=1 then 45
- NEXT k
- locate x,y:print " "
- T = 0
- GOSUB 600
- 110 INPUT "How many to Reverse";R
- IF R<=0 THEN print "Bye": if isrun then run "menu" else end
- IF R<=N THEN 150
- PRINT "Error: Number must be less than ";N:GOTO 110
- 150 T=T+1
- FOR K=1 TO INT(R/2)
- Z=A(K)
- A(K)=A(R-K+1)
- A(R-K+1)=Z
- NEXT K
- GOSUB 600
- f=0
- FOR K=1 TO N
- IF A(K)<>K THEN f=1
- NEXT K
- if f=1 then goto 110
- PRINT"You won in ";T;" moves"
- print "New Game ... (0 to Quit)" : goto 10
- 600 PRINT:FOR K=1 TO N:PRINT " ";A(K);: NEXT K
- PRINT : PRINT : RETURN
- ə