'MS-DOS QBasic 1.0 DIM a(1 TO 20) AS SINGLE, b(1 TO 20) AS SINGLE CLS RANDOMIZE TIMER PRINT "Massiv a" j = 0 FOR i = 1 TO 20 a(i) = 10 * RND - 5 PRINT a(i); IF a(i) > 0 THEN j = j + 1 b(j) = a(i) END IF NEXT i FOR i = 1 TO 20 IF a(i) <= 0 THEN j = j + 1 b(j) = a(i) END IF NEXT i PRINT PRINT "Massiv b" FOR i = 1 TO j PRINT b(i); NEXT i PRINT
DIM a(1 TO 20) AS SINGLE, b(1 TO 20) AS SINGLE
CLS
RANDOMIZE TIMER
PRINT "Massiv a"
j = 0
FOR i = 1 TO 20
a(i) = 10 * RND - 5
PRINT a(i);
IF a(i) > 0 THEN
j = j + 1
b(j) = a(i)
END IF
NEXT i
FOR i = 1 TO 20
IF a(i) <= 0 THEN
j = j + 1
b(j) = a(i)
END IF
NEXT i
PRINT
PRINT "Massiv b"
FOR i = 1 TO j
PRINT b(i);
NEXT i
PRINT
Тестовое решение:
Massiv a
-1.726111 1.835247 -4.176585 4.217188 4.836039 4.953975 .551706 .2788973
-1.588834 1.447831 1.91242 -3.830101 3.318729 1.483444 .0306803 -.3601742
1.934826 1.057516 -2.458627 .9090161
Massiv b
1.835247 4.217188 4.836039 4.953975 .551706 .2788973 1.447831 1.91242
3.318729 1.483444 .0306803 1.934826 1.057516 .9090161 -1.726111 -4.176585
-1.588834 -3.830101 -.3601742 -2.458627