vb實驗報告「找出二維陣列n×m中的鞍點」
姓名:葉大塽
班級及學號:電氣2班15050342035
日期:2023年5月26日
一.實驗目的
設計vb程式,找出二維陣列n×m中的鞍點。
二.實驗內容
找出二維陣列n×m中的鞍點,所謂的鞍點是指它在本行中值最大,在本列中值最小,輸出鞍點的行,列,有可能在乙個陣列中找不到乙個鞍點,如無鞍點則輸出「無」。
三.實驗程式
private
subcommand1_click()
dimi as
integer, j as
integer, c as
integer, r as
integer
dimn as
integer
cs1 xs
fori = 1 to4
forj = 1 to
4 private
subcommand1_click()
dimi as
integer, j as
integer, c as
integer, r as
integer
dimn as
integer
cs1 xs
fori = 1 to4
forj = 1 to4
ifa(i, 0) < a(i, j) then
c = j
a(i, 0) = a(i, j)
endif
next
n = 0
forj = 1 to4
ifa(i, 0) < a(j, c) then
print "+";
n = n + 1
endif
next
print if
n = 3 then
print "a("
& i & ","
& c & ")"; a(i, c)
next xs
endsub
public
a(4, 4) as
integer
public
subxs()
dimi as
integer, j as
integer
fori = 1 to4
forj = 0 to4
form1.print a(i, j); " ";
next
form1.print
next
endsub
public
subcs0()
a(1, 1) = 1
a(1, 2) = 1
a(1, 3) = 1
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 1
a(2, 3) = 1
a(2, 4) = 1
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 1
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 1
a(4, 4) = 1
endsub
public
subcs1()
a(1, 1) = 1
a(1, 2) = 2
a(1, 3) = 3
a(1, 4) = 4
a(2, 1) = 1
a(2, 2) = 1
a(2, 3) = 1
a(2, 4) = 5
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 1
a(3, 4) = 6
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 1
a(4, 4) = 7
endsub
public
subcs2()
a(1, 1) = 1
a(1, 2) = 1
a(1, 3) = 5
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 2
a(2, 3) = 4
a(2, 4) = 3
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 6
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 7
a(4, 4) = 1
endsub
public
subcs3()
a(1, 1) = 1
a(1, 2) = 5
a(1, 3) = 1
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 4
a(2, 3) = 2
a(2, 4) = 3
a(3, 1) = 1
a(3, 2) = 6
a(3, 3) = 1
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 7
a(4, 3) = 1
a(4, 4) = 1
endsub
ifa(i, 0) < a(i, j) then
c = j
a(i, 0) = a(i, j)
endif
next
n = 0
forj = 1 to4
ifa(i, 0) < a(j, c) then
print "+";
n = n + 1
endif
next
print if
n = 3 then
print "a("
& i & ","
& c & ")"; a(i, c)
next xs
endsub
public
a(4, 4) as
integer
public
subxs()
dimi as
integer, j as
integer
fori = 1 to4
forj = 0 to4
form1.print a(i, j); " ";
next
form1.print
next
endsub
public
subcs0()
a(1, 1) = 1
a(1, 2) = 1
a(1, 3) = 1
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 1
a(2, 3) = 1
a(2, 4) = 1
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 1
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 1
a(4, 4) = 1
endsub
public
subcs1()
a(1, 1) = 1
a(1, 2) = 2
a(1, 3) = 3
a(1, 4) = 4
a(2, 1) = 1
a(2, 2) = 1
a(2, 3) = 1
a(2, 4) = 5
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 1
a(3, 4) = 6
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 1
a(4, 4) = 7
endsub
public
subcs2()
a(1, 1) = 1
a(1, 2) = 1
a(1, 3) = 5
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 2
a(2, 3) = 4
a(2, 4) = 3
a(3, 1) = 1
a(3, 2) = 1
a(3, 3) = 6
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 1
a(4, 3) = 7
a(4, 4) = 1
endsub
public
subcs3()
a(1, 1) = 1
a(1, 2) = 5
a(1, 3) = 1
a(1, 4) = 1
a(2, 1) = 1
a(2, 2) = 4
a(2, 3) = 2
a(2, 4) = 3
a(3, 1) = 1
a(3, 2) = 6
a(3, 3) = 1
a(3, 4) = 1
a(4, 1) = 1
a(4, 2) = 7
a(4, 3) = 1
a(4, 4) = 1
endsub
四.實驗問題及解決方法
對程式無從下手,還的繼續學習。vb的確是很實用的軟體,學好前途無量。但是也確實難學,學了這麼久了,我還沒有看出其中的要點,還不能真正入門,感覺太難。以後再接再厲吧
c 實驗十二 陣列(二維)
先通過乙個二維陣列儲存學生相關的資訊 為了更直觀的 決定用字串陣列來儲存資料 當然在計算的時候要轉變格式,實驗十二 陣列 二維 cpp 定義控制台應用程式的入口點。include stdafx.h includeusing namespace std includeint main cout 當前成...
實驗6 5 尋找二維陣列中的鞍點
問題描述 輸入乙個4 4的矩陣中的所有元素,設其最多只有乙個鞍點,尋找該鞍點,如果有,則輸出其下標及對應的值,若沒有,則輸出 no 鞍點是指二維陣列中的乙個元素,在該行上最大,在該列上最小。輸入形式 輸入16個整數,存放在乙個4 4的二維陣列中 輸出形式 若有鞍點,則輸出其下標 兩個整數 和對應的值...
二維陣列中查詢
1.問題描述 在乙個二維陣列中,每一行按照從左到右的遞增順序排序,每一列按照從上到下的遞增的順序排序,請完成這樣乙個函式,輸入這樣的乙個二維陣列和乙個整數,判斷陣列是否含有該整數。來自 劍指offer 2.分析 首先選取陣列中右上角的數字。如果該數字等於要查詢的數字,查詢過程結束 如果該數字大於要查...