Date: October 28th, 2009
Time: 14:10-16:00
Open book; turn off computer & mobile phone
10 REM: ===== Prime Number =====
20 DIM A(100)
30 FOR I = 2 to 100
40 A(I)=1
50 NEXT I
60 FOR I = 2 TO 100
70 IF A(I)=0 THEN 130
80 PRINT I;
90 IF I>50 THEN 130
100 FOR J=2 TO INT(100/I)
110 A(I*J) = 0
120 NEXT J
130 NEXT I
140 PRINT
10 INPUT "N = "; NIf we want to obatin the following results, what expressions should be filled into the two blanks, respectively?
20 DO WHILE N<>0
30 FOR I=N TO 1 STEP -1
40 GOSUB 130
50 NEXT I
60 FOR I= (1) TO N
70 GOSUB 130
80 NEXT I
90 INPUT "N = "; N
100 LOOP
110 END
130 REM: --- subprogram ---
140 W = (2)
150 FOR J=1 TO I
160 PRINT "*";
170 NEXT J
180 PRINT SPC(W);
190 FOR J=1 TO I
200 PRINT "*";
210 NEXT J
220 PRINT
230 RETURN
N = ? 5
***** *****
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
***** *****
N = ? 6
****** ******
***** *****
**** ****
*** ***
** **
* *
** **
*** ***
**** ****
***** *****
****** ******
N = ? 0
bwBASIC: