41
29
Guess the number
Assume you wish to guess a randomly chosen number between 1 and 1000.
Simple guessing will require, on average, 500 tries to find the answer.
This program will tell you if your guess is larger or smaller than a number (which it chooses),
so that, proceeding logically, it should be possible to find the answer within 11 attempts.
Program
1000 Ran #+ l → X:?→ A:0→ D:Lbl 1:D +1→ D:A = X ⇒ Goto
3:X > A ⇒ Goto 2:?→ A:Goto 1:Lbl 2:?→ B:B → A:Goto 1:
Lbl 3:X
D <
68 STEP
>
Running the Program
Enter a random number and press
.
If the answer is smaller than the number you entered,
“
A?
”
will be displayed.
If the answer is larger than the number you entered,
“
B?
”
will be displayed.
When the number you enter is the correct answer,
“X”
will be displayed, along with the answer
ff
and the number of attempts made.
Prog
1
EXE
S A
R
P1
P1 P2 P3 P4
G
S A
R
P1
P1 P2 P3 P4
G
Disp
S A
R
P1
P1 P2 P3 P4
G
Disp
S A
R
P1
P1 P2 P3 P4
G
関数電卓事例集
.book 4
1
ページ
2002年9月2日 月曜日 午後6時51分
Содержание 3950P
Страница 1: ......
Страница 46: ...MEMO MEMO MEMO MEMO...
Страница 47: ...Authors Dr Yuichi Takeda Research and Development Initiative Chuo University...
Страница 48: ......