c语言求鞍点的程序,求告知我错在哪里了

c语言求鞍点的程序,求告知我错在哪里了,第1张

楼上说的对,你在定义数组的时候,计算机会在内存中为你的数组分配空间,这个过程在你输入之前就已经完成了,而你的n是个未知数,所以就造成这个错误了。问题在于,你是知道了n,但计算机不知道,要么直接定义一个大一点的数组,比如a【100】【100】,输入别超过100就行,这样的话应该就没问题了。

Option Explicit

Option Base 1

Dim a(4, 5) As Integer

Dim i As Integer, j As Integer, m As Integer, p As Integer, t As Integer, f As Integer, n As Integer, s As Integer

Private Sub Command1_Click()

Randomize

Picture1.Cls

For i = 1 To 4

For j = 1 To 5

a(i, j) = Int(Rnd * 100)

Picture1.Print a(i, j)

Next j

Picture1.Print

Next i

End Sub

Private Sub Command2_Click()

p = 0

For i = 1 To 4

m = a(i, 1)

For j = 1 To 5

If a(i, j) >= m Then m = a(i, j): t = j

Next j

n = a(1, t)

For f = 1 To 4

If a(f, t) <= n Then n = a(f, t)

Next f

If m = n Then

Print MsgBox(i &" " &t, 64, "行号和列号")

'Print "行号和列号分别是" &i &t

p = p + 1

End If

Next i

If p = 0 Then Print MsgBox("鞍点不存在", 64, "行号和列号")

End Sub

Private Sub Command3_Click()

Picture1.Cls

Cls

End Sub

Private Sub Command4_Click()

End

End Sub

Private Sub Form_Load()

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11419025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-16
下一篇 2023-05-16

发表评论

登录后才能评论

评论列表(0条)

保存