利用随机函数生成一个6 行6列的整型数组(数据在100~300范围内),找出某个指定行内最大元素所在的列号。

来源:百度知道 编辑:UC知道 时间:2024/05/30 00:51:29
求指定行内最大元素所在的列号用Function过程实现。输出数组所有数据,然用InputBox函数输入行号,调用Function过程后输出该行最大元素的列号。

很简单的,但要打好几个字,才5分呀?告诉你方法

随机 int( rnd()*200+100 ) 就是你要的数
其他的循环就行了

打点字吧

dim x(5,5) as int

sub drawint()

dim col as int
dim row as int
dim s as string

for row = 0 to 5
for col = 0 to 5
x(row,col)= rnd()*201+100
s = s & chr(9) & x(row,col)
next
s = s & vbcrlf
next

cls
print s

end sub

function getrowmax(byval row as int )
dim col as int
dim m as int
for col = 0 to 5
if x(row,col)>m then m = (row,col)
next
getrowmax = m
end funtion

'加个按钮,打印内容 代码
sub command1_click()
drawint
end sub

'加个按钮,用来input

sub command2_click()
dim s as string
s = input ("输入行号:(1-6)")

dim i as int
if isnumeric(s) then
i = int(s)
if i <1 or i >6 then
msgbox "请输入1-6的整数"
else
msgbox "第&