№143
DIM n AS INTEGER
CLS
INPUT "n=", n
REDIM a(1 TO n) AS INTEGER
RANDOMIZE TIMER
FOR i = 1 TO n
a(i) = INT(50 * RND)
PRINT a(i);
NEXT i
PRINT
FOR i = 1 TO n
IF a(i) MOD 2 = 0 THEN a(i) = 2 * a(i)
PRINT a(i);
NEXT i
PRINT
Пример
n=13
22 28 35 7 48 1 23 31 23 0 20 29 28
44 56 35 7 96 1 23 31 23 0 40 29 56
№146
DIM n AS INTEGER
CLS
DIM a(1 TO 20) AS INTEGER
RANDOMIZE TIMER
PRINT "A:";
FOR i = 1 TO 20
a(i) = INT(99 * RND)
PRINT a(i);
NEXT i
PRINT
DIM b(1 TO 10) AS INTEGER, c(1 TO 10) AS INTEGER
ib = 1: ic = 1
FOR i = 1 TO 20
IF i MOD 2 = 0 THEN
b(ib) = a(i)
ib = ib + 1
ELSE
c(ic) = a(i)
ic = ic + 1
END IF
NEXT i
PRINT "B: ";
FOR i = 1 TO 10
PRINT b(i);
NEXT i
PRINT
PRINT "C: ";
FOR i = 1 TO 10
PRINT c(i);
NEXT i
PRINT
Пример
A: 10 13 38 1 58 43 37 58 54 80 83 68 1 38 42 20 84 89 2 29
B: 13 1 43 58 80 68 38 20 89 29
C: 10 38 58 37 54 83 1 42 84 2