mirror of
https://github.com/rfivet/BCG101.git
synced 2024-12-20 17:16:23 -05:00
39 lines
902 B
QBasic
39 lines
902 B
QBasic
|
1 PRINT "THIS IS A NUMBER GUESSING GAME. I'LL THINK"
|
||
|
2 PRINT "OF A NUMBER BETWEEN 1 AND ANY LIMIT YOU WANT."
|
||
|
3 PRINT "THEN YOU HAVE TO GUESS WHAT IT IS."
|
||
|
4 PRINT
|
||
|
5 PRINT "WHAT LIMIT DO YOU WANT";
|
||
|
6 INPUT L
|
||
|
7 PRINT
|
||
|
8 L1=INT(LOG(L)/LOG(2))+1
|
||
|
9 RANDOMIZE
|
||
|
10 PRINT"I'M THINKING OF A NUMBER BETWEEN 1 AND"L
|
||
|
11 G=1
|
||
|
14 PRINT "NOW YOU TRY TO GUESS WHAT IT IS"
|
||
|
15 M=INT(L*RND(0)+1)
|
||
|
20 INPUT N
|
||
|
21 IF N>0 THEN 25
|
||
|
22 GOSUB70
|
||
|
23 GOTO1
|
||
|
25 IF N=M THEN 50
|
||
|
30 G=G+1
|
||
|
31 IF N>M THEN 40
|
||
|
32 PRINT "TOO LOW. GUESS AGAIN."
|
||
|
33 GOTO 20
|
||
|
40 PRINT "TOO HIGH. GUESS AGAIN."
|
||
|
42 GOTO 20
|
||
|
50 PRINT "THAT'S IT! YOU GOT IT IN"G"TRIES."
|
||
|
52 IF G<L1 THEN 58
|
||
|
54 IF G=L1 THEN 60
|
||
|
56 PRINT"YOU SHOULD HAVE BEEN ABLE TO GET IT IN ONLY"L1"."
|
||
|
57 GOTO 65
|
||
|
58 PRINT"VERY ";
|
||
|
60 PRINT"GOOD!"
|
||
|
65 GOSUB70
|
||
|
66 GOTO10
|
||
|
70 FOR H=1 TO 5
|
||
|
71 PRINT
|
||
|
72 NEXT H
|
||
|
73 RETURN
|
||
|
99 END
|