Задан массив х={Хi}, i = 1,2…,n; n-число элементов массива (n<=24) a;b. Сформировать массив y={Yk} из элементов массива х больших а, но меньших или равных b (a

CLS
DO
 INPUT "Input size of source array (2 to 24): N = "; N
LOOP WHILE N < 2 OR N > 24
DO
 INPUT "a = "; a
 INPUT "b = "; b
LOOP UNTIL a <= b
DIM X(1 TO N)
'RANDOMIZE TIMER
L = 0
FOR i = 1 TO N
 'X(i) = FIX(RND * 101 - 50)
 PRINT "X("; i; ") = ";
 INPUT X(i)
 IF (X(i) > a) AND (X(i) <= b) THEN
  L = L + 1
 END IF
NEXT
IF L = 0 THEN
 PRINT "No values from A to B found"
 END
END IF
DIM Y(1 TO L)
PRINT "Array Y has "; L; " values."
KP = 0: KN = 0: K0 = 0
L = 1
FOR i = 1 TO N
 IF X(i) > a AND X(i) <= b THEN
  Y(L) = X(i)
  L = L + 1
 END IF
 IF X(i) = 0 THEN
  K0 = K0 + 1
 ELSEIF X(i) < 0 THEN
  KN = KN + 1
 ELSE
  KP = KP + 1
 END IF
NEXT
PRINT "Negative: "; KN
PRINT "Zero: "; K0
PRINT "Positive: "; KP

Leave a Comment