Заданы одномерные массивы X(N),Y(M),Z(L). Для каждого из них: 1) Подсчитать количество элементов равных нулю 2)Дробные элементы увеличить в 20 раз. Подсчитать количество преобразованных элементов — QBasic(Бейсик)

INPUT "vvedite razmer massiva X ", n
INPUT "vvedite razmer massiva Y ", m
INPUT "vvedite razmer massiva Z ", l
DIM X(n), Y(m), Z(l)

FOR i = 1 TO n
    INPUT "vvedite element massiva X ", X(i)
NEXT

FOR i = 1 TO m
    INPUT "vvedite element massiva Y ", Y(i)
NEXT

FOR i = 1 TO l
    INPUT "vvedite element massiva Z ", Z(i)
NEXT

PRINT "Massiv X "
FOR i = 1 TO n
    PRINT X(i);
NEXT
PRINT
PRINT "Massiv Y "
FOR i = 1 TO m
    PRINT Y(i);
NEXT
PRINT
PRINT "Massiv Z"
FOR i = 1 TO l
    PRINT Z(i);
NEXT i
PRINT

'Schitaem nulevie el-ti
FOR i = 1 TO n
    IF X(i) = 0 THEN nulX = nulX + 1
NEXT i ' Eto bil pervii massiv

FOR i = 1 TO m
    IF Y(i) = 0 THEN nulY = nulY + 1
NEXT i ' Eto bil vtoroi massiv

FOR i = 1 TO l
    IF Z(i) = 0 THEN nulZ = nulZ + 1
NEXT i ' I sootv. tretii

'  Pechataem kol-vo nulevikh el-v
PRINT "Nulevyh v X:"; nulX
PRINT "Nulevyh v Y:"; nulY
PRINT "Nulevyh v Z:"; nulZ

'Ishchem veshchestvennie chisla & domnozhaem
PRINT "Novyj Massiv X "
FOR i = 1 TO n
    IF (X(i) - INT(X(i))) <> 0 THEN X(i) = X(i) * 20: UmnX = UmnX + 1
    PRINT X(i);
NEXT i
PRINT ' Eto bil pervii massiv
PRINT "Novyj Massiv Y "
FOR i = 1 TO m
    IF (Y(i) - INT(Y(i))) <> 0 THEN Y(i) = Y(i) * 20: UmnY = UmnY + 1
    PRINT Y(i);
NEXT i
PRINT ' Eto bil vtoroi massiv
PRINT "Novyj Massiv Z "
FOR i = 1 TO l
    IF (Z(i) - INT(Z(i))) <> 0 THEN Z(i) = Z(i) * 20: UmnZ = UmnZ + 1
    PRINT Z(i);
NEXT i
PRINT ' Eto bil poslednii massiv
PRINT "Veshestvennyh v X:"; UmnX
PRINT "Veshestvennyh v Y:"; UmnY
PRINT "Veshestvennyh v Z:"; UmnZ
END ' Konets programmi

Тестирование выполнено в программе QB64 ( Скачать )

Leave a Comment