Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Sub Menor()
- '
- ' Menor Macro
- '
- ' Atalho por teclado: Ctrl+m
- '
- 'intr variaveis
- Dim n As Integer, menorDimensao As Integer, j As Single, i As Single
- n = InputBox("tamanho da dimensao (de 10 a 100)?") - 1
- ReDim mat(n, n) As Integer
- ReDim matrizEntrada(n, n) As Integer
- 'parte 1
- 'preencher o array e as celulas
- For j = 0 To n
- For i = 0 To n
- mat(j, i) = Int(Rnd() + 0.5)
- Cells(j + 1, i + 1).Value = mat(j, i)
- Next i
- Next j
- matrizEntrada = mat
- Call CalculaDimensao(matrizEntrada(), menorDimensao, n, j, i)
- End Sub
- 'parte 2
- Function CalculaDimensao(ByRef matrizEntrada() As Integer, menorDimensao As Integer, n As Integer, j As Single, i As Single) As Integer
- menorDimensao = 0
- Do
- For j = 0 To n
- For i = 0 To n
- menorDimensao = menorDimensao + matrizEntrada(j, i)
- Next i
- Next j
- menorDimensao = menorDimensao
- Loop While menorDimensao < 100
- MsgBox (i & " " & j)
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement