Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub sagasg()
- Dim n As Integer, m As Integer, a() As Integer, i As Integer, j As Integer, min As Integer, max As Integer, min_ As Integer, max_ As Integer
- n = InputBox("Enter N, my sweety")
- m = InputBox("Enter M, my sweet prince")
- ReDim a(n, m)
- For i = 1 To n
- For j = 1 To m
- a(i, j) = InputBox("Enter A[" & i & " , " & j & "], my dear friend")
- Next j
- Next i
- MsgBox (Replace(a, n, m))
- End Sub
- Function Replace(a() As Integer, n As Integer, m As Integer)
- Dim i As Integer, j As Integer, min As Integer, max As Integer, min_ As Integer, max_ As Integer
- max_ = 1
- min_ = 1
- max = a(1, 1)
- min = a(1, 1)
- For i = 1 To n
- For j = 1 To m
- If (a(i, j) < min) Then
- min = a(i, j)
- min_ = i
- End If
- If (a(i, j) > max) Then
- max = a(i, j)
- max_ = i
- End If
- Next j
- Next i
- Dim buffer() As Integer
- ReDim buffer(m)
- For i = 1 To m
- buffer(i) = a(max_, i)
- Next i
- For i = 1 To m
- a(max_, i) = a(min, i)
- Next i
- For i = 1 To m
- a(min_, i) = buffer(i)
- Next i
- Dim ans As String
- For i = 1 To n
- For j = 1 To m
- ans = ans & " " & a(i, j)
- Next j
- ans = ans & Chr(13)
- Next i
- Replace = ans
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement