vb程式設計 統計學生各分數段的人數,並輸出請高人修正該程式

2022-03-06 06:07:33 字數 5458 閱讀 5342

1樓:匿名使用者

唯一的問題似乎就是應當將end sub 移到下一行。

vb程式,隨機產生20個學生的成績,並顯示.統計各分數段人數,即0~59,60~69,70~79,8

2樓:聽不清啊

private sub command1_click()dim a(20) as integer

clsc1 = 0: c2 = 0: c3 = 0: c4 = 0: c5 = 0: c6 = 0

randomize

print "20個成績:"

for i = 1 to 20

a(i) = int(rnd * 101)print a(i);

if i mod 10 = 0 then printnext i

for i = 1 to 20

if a(i) = 100 then

c1 = c1 + 1

else

if a(i) > 89 then

c2 = c2 + 1

else

if a(i) > 79 then

c3 = c3 + 1

else

if a(i) > 69 then

c4 = c4 + 1

else

if a(i) > 59 then

c5 = c5 + 1

else

c6 = c6 + 1

end if

end if

end if

end if

end if

next i

print: print "統計結果:"

print "  100分:"; c1

print "90~99分:"; c2

print "80~89分:"; c3

print "70~79分:"; c4

print "60~69分:"; c5

print " 0~59分:"; c6

end sub

或者換一種寫法(執行效果完全一樣):

private sub command1_click()dim a(20) as integer

dim cj(5 to 10) as integerclsrandomize

print "20個成績:"

for i = 1 to 20

a(i) = int(rnd * 101)print a(i);

t = a(i) \ 10

if t < 5 then t = 5

cj(t) = cj(t) + 1

if i mod 10 = 0 then printnext i

print: print "統計結果:"

print "  100分:"; cj(10)print "90~99分:"; cj(9)print "80~89分:

"; cj(8)print "70~79分:"; cj(7)print "60~69分:"; cj(6)print " 0~59分:

"; cj(5)end sub

3樓:匿名使用者

'新增窗體form1,按鈕command1,然後新增如下**:

private sub command1_click()dim s(19), a(4), i, temp as integer

me.autoredraw = true

clsfor i = 0 to 19

randomize

s(i) = int(rnd * 101)temp = int(s(i) / 10)if temp = 10 then

a(4) = a(4) + 1

elseif temp < 5 then

a(0) = a(0) + 1

else

a(temp - 5) = a(temp - 5) + 1end if

print s(i)

next

print

print "各分數段人數分別是:" & join(a, " ")end sub

用vb程式語言 編寫程式,從鍵盤輸入學生成績,然後統計學生總人數和各分段的人數 5

vb程式設計:隨機產生20個學生課程分數並顯示,統計各分數段人數,顯示統計結果

4樓:匿名使用者

private sub command1_click()dim a(0 to 4) as integer, i as integer, iscore as integer

randomize

for i = 1 to 20

iscore = rnd * 100

if i mod 4 = 0 then print '每4個一行print "學生 " & i & " 成績: " & iscore,

if iscore >= 90 then

a(4) = a(4) + 1

elseif iscore >= 80 thena(3) = a(3) + 1

elseif iscore >= 70 thena(2) = a(2) + 1

elseif iscore >= 60 thena(1) = a(1) + 1

else

a(0) = a(0) + 1

end if

next i

print '換行

print "0-59共有: " & a(0) & " 人"

print "60-69共有: " & a(1) & " 人"

print "70-79共有: " & a(2) & " 人"

print "80-89共有: " & a(3) & " 人"

print "90-100共有: " & a(4) & " 人"

end sub

5樓:玫瑰為你盛開

private sub command1_click()dim score(0 to 19) as single, i%, a5%, a6%, a7%, a8%, a9%

randomize

print "20個學生課程分數為:"

for i = 0 to 19

score(i) = int(101 * rnd)print score(i);

select case score(i)

case 0 to 59

a5 = a5 + 1

case 60 to 69

a6 = a6 + 1

case 70 to 79

a7 = a7 + 1

case 80 to 89

a8 = a8 + 1

case 90 to 100

a9 = a9 + 1

end select

next

print

print "分數段0-59:"; a5

print "分數段60-69:"; a6print "分數段70-79:"; a7print "分數段80-89:

"; a8print "分數段90-100:"; a9end sub

在文字框中輸入30個學生的成績,如何用vb程式設計統計各分數段的人數?

vb程式設計 隨機產生20個學生的成績,統計各分數段人數 5

6樓:匿名使用者

辦法是有,不過很難實現,也不實際。

如果可以的話,先將值放到label或者textbox裡面,然後再生成**

vb程式,隨機產生20個學生的成績,並顯示.統計各分數段人數,即0~59,60~69,70~79,80~89,90~100,並顯示結果

7樓:微標科技

'新增窗體form1,按鈕command1,然後新增如下**:

private sub command1_click()dim s(19), a(4), i, temp as integer

me.autoredraw = true

clsfor i = 0 to 19

randomize

s(i) = int(rnd * 101)temp = int(s(i) / 10)if temp = 10 then

a(4) = a(4) + 1

elseif temp < 5 then

a(0) = a(0) + 1

else

a(temp - 5) = a(temp - 5) + 1end if

print s(i)

next

print

print "各分數段人數分別是:" & join(a, " ")end sub

[vb]隨機產生20個學生的成績,統計各分數段人數。

8樓:遠風的夢想家

option explicit

dim d(1 to 20) as integerprivate sub command1_click()dim i as integer

picture1.cls

for i = 1 to 20

d(i) = int(rnd() * 100) + 1picture1.print format(d(i), " 0");

if i mod 4 = 0 then picture1.printnext i

end sub

private sub command2_click()dim b(5) as integer

dim i as integer

picture2.cls

for i = 1 to 20

select case d(i)

case 0 to 59

b(1) = b(1) + 1

case 60 to 69

b(2) = b(2) + 1

case 70 to 79

b(3) = b(3) + 1

case 80 to 89

b(4) = b(4) + 1

case 90 to 100

b(5) = b(5) + 1

end select

next

picture2.print "0~59:"; b(1); "個"

picture2.print "60~79:"; b(2); "個"

picture2.print "70~89:"; b(3); "個"

picture2.print "80~99:"; b(4); "個"

picture2.print "90~100:"; b(5); "個"

end sub

private sub form_load()command1.caption = "產生並顯示資料"

command2.caption = "統計分數段人數"

end sub

統計學原理什麼是統計學課後答案,統計學原理宮春子主編課後習題答案

統計學統計學是一門研究隨機現象,以推斷為特徵的方 科學,由部分推及全體 的思想貫穿於統計學的始終。具體地說,它是研究如何蒐集 整理 分析反映事物總體資訊的數字資料,並以此為依據,對總體特徵進行推斷的原理和方法。用統計來認識事物的步驟是 研究設計 抽樣調查 統計推斷 結論。這裡,研究設計就是制定調查研...

統計學學哪些內容?統計學專業學什麼

統計學專業不是僅僅像其表面的文字表示,只是統計數字,而是包含了調查 收集 分析 等,應用的範圍十分廣泛,因此也要求畢業生掌握紮實的統計基礎理論,為未來奠定堅實的基礎。統計學專業課程。數學分析 幾何代數 數學實驗,常微分方程,復變函式,實變與泛函 概率論 數理統計,抽樣調查,隨機過程,多元統計,計算機...

統計學要怎麼學?統計學學些什麼

首先,統計是一種思想,它的產生源於一種需要。統計的產生,對於我們今天的生活影響非常巨大,各個方法所帶來的結果影響我們,給我們帶來益處,解決生活中的問題。所以,學習統計學,一定要理解這種思想,理解統計學的目的。其次,統計學的各種方法,也來自於實際需要。比較特別的是,每種方法都有其數學基礎,這是統計學比...