Дана матрица A размерности 3*5. получить матрицу по правилу С(i,j)=a(i,j)*min(a(k,j)) — QBasic(Бейсик)

CLS
 
DIM A(3, 5)
FOR i = 0 TO 2
  FOR j = 0 TO 4
    PRINT "A("; i; ", "; j; ")= ";
    INPUT "", A(i, j)
  NEXT j
NEXT i
 
DIM minArr(5)
FOR i = 0 TO 4
  minArr(i) = A(0, i)
  FOR j = 0 TO 2
    IF minArr(i) > A(j, i) THEN
      minArr(i) = A(j, i)
    END IF
  NEXT j
NEXT i
 
DIM C(3, 5)
FOR i = 0 TO 4
  FOR j = 0 TO 2
    C(j, i) = A(j, i) * minArr(i)
  NEXT j
NEXT i
 
FOR i = 0 TO 2
 PRINT C(i, 0); C(i, 1); C(i, 2); C(i, 3); C(i, 4)
NEXT i

Visual Basic

Dim min_arr(5) 'массив минимумов
For i=0 to 4
  min_arr(i) = A(0,i)
  For j=0 to 2
    If min_arr(i) > A(j,i) Then
      min_arr(i) = A(j,i)
    End if
  Next j
Next i
 
For i=0 to 4
  For j = 0 to 2
    C(j,i) = A(j,i) * min_arr(i)
  Next j
Next i

Leave a Comment