有一个5*8的矩阵,编程求出其最大值所在位置
答案:2 悬赏:50 手机版
解决时间 2021-02-01 17:47
- 提问者网友:十年饮冰
- 2021-02-01 11:27
有一个5*8的矩阵,编程求出其最大值所在位置
最佳答案
- 五星知识达人网友:毛毛
- 2021-02-01 11:54
Dim a(5, 8) As Integer
Private Sub Command1_Click()
Dim m As Integer
m = 100
For i = 1 To 5
For j = 1 To 8
a(i, j) = Int(Rnd * 90 + 10)
If a(i, j) < m Then m = a(i, j)
Print a(i, j);
Next j
Print
Next i
For i = 1 To 5
For j = 1 To 8
If a(i, j) = m Then Print m, i, j
Next j
Print
Next i
End Sub
Private Sub Command1_Click()
Dim m As Integer
m = 100
For i = 1 To 5
For j = 1 To 8
a(i, j) = Int(Rnd * 90 + 10)
If a(i, j) < m Then m = a(i, j)
Print a(i, j);
Next j
Next i
For i = 1 To 5
For j = 1 To 8
If a(i, j) = m Then Print m, i, j
Next j
Next i
End Sub
全部回答
- 1楼网友:第幾種人
- 2021-02-01 13:13
举个例子,希望有所帮助。
代码
% 有一个4行5列的矩阵,编程求出其最大值以及最大值所处位置 clc; clear all; a = rand(4, 5); m = a(1); ind = [1 1]; for i = 1 : size(a, 1) for j = 1 : size(a, 2) if m < a(i, j) m = a(i, j); ind = [i j]; end end end m ind a(ind(1), ind(2)) 结果
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯