Get a proper statement
1988/10/01 Arrojeria, Eustakio - Elhuyar Zientziaren Komunikazioa | Lizaso, Pili - Informatika SailaElhuyar Fundazioa Iturria: Elhuyar aldizkaria
Let's make known the rules of the game:
- A numeric set of 1 to 25 will be displayed. The program will calculate the numeric value of an expression composed of four numbers and
- You should get an expression that gives this value as a result. To
do this you can use the operators (+,–,*) and 4 numbers of the set. Since
there may be more than one statement that provides the same value, any of them will be considered
good, even if not evaluated by the program.
operators (+,–,*) of the following.
- Numbers and operators cannot be repeated. All agents must be used (+,–,*).
- The evaluation of the declaration will not take into account the priority levels of the agents.
They will be applied from left to right.
E.g. 3 + 4 *2 = 14 and no 11
As you may have seen, the '/' operator has not been taken into account and
has been because the program randomly takes numbers and operators in formulating the expression and using '/' can make the divisions to be performed not complete, with decimal numbers. We didn't want to
complicate the game too much and that's why we found it better to leave it out.
The program is divided into the following parts.
- 40-50: Store the numbers and symbols to use
- 520-600: Verification of response
60: Define the positions of the 8 numbers of the set
70-130: From 1 to 25 take 8 randomly
140-260: Evaluate as statement 270-320
emerges: Appearance of the presentation screen and user response
330-510: Evaluate the declaration issued by the user
Evaluate the declaration issued by the user
This expression (ERAN$) will be a string of characters for the program. Therefore, the black and white
spaces involved are also significant. Analyze the character string in characters, distinguishing
between themes (numeric strings) and agents (+,–,*) and simultaneously calculating the value
of the expression.
For this distinction it must be taken into account that in the
range of two themes there can be only agents or spaces ahead and behind the agent.
10(1) Getting the number
20 DIM DIG(25):DIM
30 CLS:SCREEN 2:KEY
280 CIRCLE (100,65),100
290 FOR I=1 TO 8:LOCATE POSI(I,I),POSI(IM,I):PRINT
AUK The statement may be: ";
530 LOCATE 25,20:PRINT "You want to continue (S/N/?"
540 TE$=INKEY$:WHILE TE$ "":TE$=INKEY$:WEND
550 WHILE$ "B" AND TE$ "b" AND TE$ "E" AND TE$ "e":
560 IF TE$="B" OR TE$="b"THEN 30
570 LOCATE 23,1:PRINT SPC(79):LOCATE 25,1:PRINT SPC(79):LOCATE 22,30:
PRINT "Goodbye to another! ";
GET NUMBER 580 END
600 REMN AMAIA