高分求答案(VB程式設計高手進)有追加

2021-09-30 17:07:32 字數 3474 閱讀 7056

1樓:匿名使用者

private sub command1_click()

'第1題,需要在窗體中加按鈕command1

dim i as integer, j as integer, ka as integer, kc as integer

dim b as boolean

dim a() as integer, c() as integer

for i = 1 to 100

if i = 1 then b = false else b = true

for j = 1 to i

if i mod j = 0 and j <> i and i <> 1 then b = false

next

if b then

if i mod 2 = 0 then

ka = ka + 1

redim preserve a(1 to ka)

a(ka) = i

else

kc = kc + 1

redim preserve c(1 to kc)

c(kc) = i

end if

end if

next

print "1~100內的偶素數"

for i = 1 to ka

print a(ka)

next

print "1~100內的奇素數"

for i = 1 to kc

print c(kc)

next

end sub

private sub command2_click()

'第2題,需要在窗體中加按鈕command2

dim i as integer, j as integer, k as double

print "1~100內的勾股數"

for i = 1 to 100

for j = i + 1 to 100

k = sqr(i * i + j * j)

if k <= 100 and k - int(k) = 0 then print i & " " & j & " " & k

next

next

end sub

private sub command3_click()

'第3題,需要在窗體中加按鈕command3和文字框text1、text2

'文字框text1中為輸入,文字框text2中為輸出

dim sta as string, stb as string

dim i as long, j as long

sta = text1.text

j = len(sta)

stb = ""

for i = j to 1 step -1

stb = stb & mid(sta, i, 1)

next

text2.text = stb

end sub

private sub command4_click()

'第4題,需要在窗體中加按鈕command4和文字框text3、text4、text5

'文字框text3中為係數a輸入,文字框text4中為係數b輸入,文字框text5中為係數c輸入

dim a as double, b as double, c as double, d as double, x1 as double, x2 as double

if not isnumeric(text3.text) then

msgbox "輸入的係數a不是有效數字", , "錯誤"

exit sub

end if

if not isnumeric(text4.text) then

msgbox "輸入的係數b不是有效數字", , "錯誤"

exit sub

end if

if not isnumeric(text5.text) then

msgbox "輸入的係數c不是有效數字", , "錯誤"

exit sub

end if

a = val(text3.text)

b = val(text4.text)

c = val(text5.text)

d = b * b - 4 * a * c

if d < 0 then

msgbox "無有理數解", , ""

exit sub

end if

x1 = (-b + d) / (2 * a)

x2 = (-b - d) / (2 * a)

print "x的第一個解"

print format(x1, "general number")

print "x的第二個解"

print format(x2, "general number")

end sub

private sub command5_click()

'第5題,需要在窗體中加按鈕command5

dim a(1 to 10, 1 to 10) as double, b as double

dim i as integer, j as integer, k as integer, t as integer

for i = 1 to 10

for j = 1 to 10

a(i, j) = val(inputbox("請輸入第" & i & "名選手的第" & j & "個得分", "輸入"))

next

b = a(i, 1)

k = 1

for j = 2 to 10

if b < a(i, j) then

b = a(i, j)

k = j

end if

next

b = a(i, 1)

t = 1

for j = 2 to 10

if b > a(i, j) then

b = a(i, j)

t = j

end if

next

if k = t then

a(i, 1) = 0

a(i, 2) = 0

else

a(i, k) = 0

a(i, t) = 0

end if

b = 0

for j = 1 to 10

b = b + a(i, j)

next

b = b / 8

msgbox "第" & i & "名選手的平均分是" & b, , "輸出"

next

end sub

2樓:匿名使用者

...素數除了2都是奇數

3樓:好幾碗粥

...素數除了2都是奇數

回答者: murderor - 江湖少俠 七級 2009-6-17 10:21

急求VB程式設計答案

private a 1 to 1000 as integer,b 1 to 1000 as integer,n as integer private sub mand1 click text1.text randomize for i 1 to 20 a i int rnd 101 100text1...

高分請高手寫一首情詩,最佳答案追加高分

網上太多用機器生成的藏頭詩,別用了 真心實意的表白才有效果 白羽千千藏頭詩 宋華僑祝楊虹生日快樂 送你一顆心表達我的愛 雙藏 宋都景美送春到 華夏明媚你逍遙 僑鄉逢春一城笑 祝願椰果顆顆俏 楊柳依依心情好 虹彩歌舞表演巧 生活小康達高標 日子愜意我樂淘 快步進取的蘊高 樂慶生日愛友鬧 更北有桃花 0...

追加高分漢服高手進急急求配色

拿我自己的復 體驗說下吧 我皮製 膚也有點偏黃 而且瘦 碎花絕bai 對是du悲劇 絕對的村姑。我只zhi有一套對襟dao襦裙 上衣和下裳都是純白雪紡 帶了淡粉色的掐牙 抹胸和腰封是白底繡地淡粉的花 上身效果還行 打點粉底可能會更好點 當初選的時候為了配色糾結好久 最後還是最沒創意的選了白的。因為平...