Даны матрицы А(10,12), В(15,10) и С(5,10). Составить программу для нахождения наименьших элементов и номеров строк и столбцов,в которых она находится — QBasic(Бейсик)

DIM A(10,12)
RANDOMIZE TIMER
FOR i=1 TO 10
FOR j=1 TO 12
A(i,j)=INT(RND*200)-100
NEXT j
NEXT i
PRINT "Matrica A"
FOR i=1 TO 10
FOR j=1 TO 12
PRINT A(i,j);
NEXT j
PRINT
NEXT i
imin=1: jmin=1: min=A(1,1)
FOR i=1 TO 10
FOR j=1 TO 12
IF A(i,j)<min THEN min=A(i,j): imin=i: jmin=j
NEXT j
NEXT i
PRINT "naimenshiy element v matrice A=";min
PRINT "nomer stroki gde on nahoditsya=";imin
PRINT "nomer stolbca gde on nahoditsya=";jmin
END
DIM B(15,10)
RANDOMIZE TIMER
FOR i=1 TO 15
FOR j=1 TO 10
B(i,j)=INT(RND*200)-100
NEXT j
NEXT i
PRINT "Matrica B"
FOR i=1 TO 15
FOR j=1 TO 10
PRINT B(i,j);
NEXT j
PRINT
NEXT i
imin=1: jmin=1: min=B(1,1)
FOR i=1 TO 15
FOR j=1 TO 10
IF B(i,j)<min THEN min=B(i,j): imin=i: jmin=j
NEXT j
NEXT i
PRINT "naimenshiy element v matrice B=";min
PRINT "nomer stroki gde on nahoditsya=";imin
PRINT "nomer stolbca gde on nahoditsya=";jmin
END
DIM C(5,10)
RANDOMIZE TIMER
FOR i=1 TO 5
FOR j=1 TO 10
C(i,j)=INT(RND*200)-100
NEXT j
NEXT i
PRINT "Matrica C"
FOR i=1 TO 5
FOR j=1 TO 10
PRINT C(i,j);
NEXT j
PRINT
NEXT i
imin=1: jmin=1: min=C(1,1)
FOR i=1 TO 5
FOR j=1 TO 10
IF C(i,j)<min THEN min=C(i,j): imin=i: jmin=j
NEXT j
NEXT i
PRINT "naimenshiy element v matrice C=";min
PRINT "nomer stroki gde on nahoditsya=";imin
PRINT "nomer stolbca gde on nahoditsya=";jmin
END

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

Leave a Comment