Читайте также:
|
|
CLS
INPUT n, m
DIM A(n, m), B(m)
FOR i = 1 TO n
FOR j = 1 TO m
INPUT A(i, j)
NEXT j, i
FOR j = 1 TO m
FOR i = 1 TO n
IF A(i, j) MOD 3 = 0 THEN K = A(i, j): EXIT FOR
NEXT i
B(j) = K
IF B(j) <> 0 THEN
FOR i = 1 TO n
A(i, j) = A(i, j) / B(j)
NEXT i
END IF
NEXT j
FOR i = 1 TO n
FOR j = 1 TO m
PRINT A(i, j);
NEXT j
NEXT i
END
Задача 10 (стр.57)
CLS
INPUT n
DIM A(n, n)
FOR i = 1 TO n
FOR j = 1 TO n
INPUT A(i, j)
NEXT j, i
max = A(1, 1)
K1 = 1
K2 = 1
FOR i = 1 TO n
FOR j = 1 TO n
IF (A(i, j) > max AND i = j) OR (A(i, j) > max AND i + j = n + 1) THEN
max = A(i, j)
K1 = i
K2 = j
END IF
NEXT j, i
C = n MOD 2 + 1
SWAP A(K1, K2), A(C, C)
FOR i = 1 TO n
FOR j = 1 TO n
PRINT A(i, j);
NEXT j
NEXT i
END
Задача 3 (стр.62)
CLS
INPUT n, m
DIM A(n, m)
FOR i = 1 TO n
FOR j = 1 TO m
INPUT A(i, j)
NEXT j, i
INPUT C
FOR i = 1 TO n
S = 0
FOR j = 1 TO m
S = S + A(i, j)
NEXT j
IF S <= C THEN K = i: EXIT FOR
NEXT i
FOR i = K TO n - 1
FOR j = 1 TO m
A(i, j) = A(i + 1, j)
NEXT j, i
n = n - 1
FOR i = 1 TO n
FOR j = 1 TO m
PRINT A(i, j);
NEXT j
NEXT i
END
Задача 4 (стр. 67)
CLS
INPUT n, m
DIM A(n + 1, m + 1)
FOR i = 1 TO n
FOR j = 1 TO m
INPUT A(i, j)
NEXT j, i
min = A(1, 1)
K1 = 1
K2 = 1
FOR i = 1 TO n
FOR j = 1 TO m
IF A(i, j) < min THEN min = A(i, j): K1 = i: K2 = j
NEXT j, i
FOR i = n TO K1 STEP -1
FOR j = 1 TO m
A(i + 1, j) = A(i, j)
NEXT j, i
n = n + 1
FOR j = 1 TO m
A(K1, j) = 0
NEXT j
FOR j = m TO K2 STEP -1
FOR i = 1 TO n
A(i, j + 1) = A(i, j)
NEXT i, j
m = m + 1
FOR i = 1 TO n
A(i, K2) = 0
NEXT i
FOR i = 1 TO n
FOR j = 1 TO m
PRINT A(i, j);
NEXT j
NEXT i
END
ЛИТЕРАТУРА
1. Г. Зельднер. Программируем на языке QBASIC 4.5. –М.: ABF, 1996.
2. О.И. Мельникова, А.Ю. Бонюшкина. Начала программирования на языке QBASIC. – М.: ЭКОМ, 1997.
Содержание
Часть первая
1. Предварительные сведения..... 1.1.Объявление массива ...... 1.2. Ввод и вывод элементов массива .....
Примеры решения типовых задач с использованием одномерных массивов......
Дата добавления: 2015-07-11; просмотров: 44 | Нарушение авторских прав