當前位置:首頁 » 考試成績 » vb輸入n個學生的成績

vb輸入n個學生的成績

發布時間: 2021-02-11 18:52:46

① VB輸入N個學生的學號和成績,列印出成績最高者的學號和成績

我用5個學生來設計,用結構體,效果圖如下:

PrivateTypestu

idAsInteger

fsAsLong

EndType

Dima(4)Asstu

DimiAsInteger

PrivateSubCommand1_Click()

Picture1.AutoRedraw=True

Ifi>=5Then

MsgBox("最多隻能輸入個學生信息"):Text1.Text="":Text2.Text=""

Text1.Locked=True:Text2.Locked=True

Else

IfText1=""OrText2=""Then

N=MsgBox("請認真填寫學生的基本信息",0+48,"提示")

IfText1=""ThenText1.SetFocus

IfText2=""ThenText2.SetFocus

Else

Witha(i)

.id=Val(Text1)

.fs=Val(Text2)

Picture1.Printi+1;Tab(6);.id;Tab(13);.fs

EndWith

Text1="":Text2=""

i=i+1

EndIf

EndIf

EndSub

PrivateSubCommand2_Click()

DimtAsstu

Picture2.Cls

Picture2.AutoRedraw=True

imax=0

ForN=1Toi-1

Ifa(N).fs>a(imax).fsThenimax=N

NextN

Picture2.Print"成績最高分是學號";a(m).id;Spc(2);"分數為";a(m).fs

② vb輸入學生人數n,輸入n個學生的成績,輸出最大成績😁

Private Sub Command1_Click()
n = CInt(InputBox("請輸入學生人數:"))
x = -1
For i = 1 To n
x = Val(InputBox("請輸入第 " & i & " 個學生的成績:專"))
If x > Max Then Max = x
Next i
MsgBox "最高屬分=" & Max
End Sub

③ 在VB編程序時,怎樣寫「輸入N名學生的成績,顯示在文本框中.」

Option Explicit
Private Sub Command1_Click()
Dim renshu%, i%, n$, f!
Text1.Text = ""
Text1.MultiLine = True
renshu% = Val(InputBox("請輸入學生的個數", "提示"))
For i% = 1 To renshu%
n$ = InputBox("請輸入第內" & Str(i%) & "個學生的名容字", "提示")
f! = Val(InputBox("請輸入第" & Str(i%) & "個學生的分數", "提示"))
Text1.Text = Text1.Text & "第" & Str(i%) & "個 名字:" & n$ & " 分數:" & f! & vbCrLf
Next i%
End Sub

按我理解給你寫的

④ 問VB怎麼編:輸入n,再輸入n個學生的成績,統計及格人數

Dim x As Integer
Dim a() As Integer
Dim i As Integer
Dim ss As Integer
Dim Score As Integer
Private Sub Form_Activate()
x = InputBox("請輸入復學生制數目")
ReDim a(1 To x)
For i = 1 To x
Score = InputBox("請輸入第" & i & "個學生的成績")
If Score >= 60 Then ss = ss + 1
Next i

MsgBox "共有" & ss & "人及格"
End Sub

⑤ vb試題:任意輸入N個學生的成績,計算平均分,並輸出n名學生的成績及平均分。急求,勿水,急求,在線

Private Sub Command1_Click()
Dim n As Integer
Dim show As String
Dim a()
n = CInt(InputBox("輸入學來生數自"))
ReDim a(n)
For i = 1 To n
a(n) = CInt(InputBox("請輸入第 " & CStr(i) & " 名學生成績"))
average = average + a(n)
Next i
For i = 1 To n
show = show & "第 " & CStr(i) & " 名成績" & Chr(13)
Next i

average = average / n
show = show & "平均值:" & average & Chr(13)
MsgBox show
End Sub

⑥ VB編程:輸入n和m,並輸入n個學生m門課程的成績,計算平均成績,並按平均成績升序排序

Dim Avg()
n = Val(InputBox("輸入學生人數N="))
M = Val(InputBox("輸入課程數M="))
ReDim Avg(n)

For i = 0 To n - 1
Sum = 0
For j = 0 To M - 1
D = Val(InputBox("輸入第 " & i + 1 & " 位同學的科目 " & j + 1 & " 的成績:"))
Sum = Sum + D
Next
Avg(i) = Sum / M
Next

For i = 0 To n - 1
For j = 0 To n - 1
If Avg(i) < Avg(j) Then
T = Avg(i)
Avg(i) = Avg(j)
Avg(j) = T
End If
Next
Next

For i = 0 To n - 1
Print Avg(i);
Next

⑦ VB輸入某班級N個學生的成績到數組X中,求成績的標准差,求標准差公式如下

^Private Sub Command1_Click()
Dim i As Integer, cj() As Integer, n As Integer, zcj As Integer, pj As Single, s As Single, q As Single
n = InputBox("請輸入學生人數:")
ReDim cj(n) As Integer
For i = 1 To n
cj(i) = InputBox("請輸入第版 " & i & " 個學生成績:權")
Next
zcj = 0
For i = 1 To n
zcj = zcj + cj(i)
Next
pj = zcj / n
s = 0
For i = 1 To n
s = s + (cj(i) - pj) ^ 2
Next
q = Sqr(s / (n - 1))

Print q
End Sub

⑧ vb利用動態數組輸入學生人數n然後輸入n個學生的學號與一門課的成績,進行如下還要計算最高分最低分

PrivateSubCommand1_Click()
Dimsno()AsString
Dimscore()AsInteger
Cls
n=Val(InputBox("輸入學生總人數","輸入人數",10))
ReDimsno(1Ton)AsString
ReDimscore(1Ton)AsInteger
Fori=1Ton
sno(i)=InputBox("輸入第"&i&"位學生的學號","學號",201500+i)
score(i)=Val(InputBox("輸入第"&i&"位學生的成績","成績",80))
Nexti

maxid=1:minid=1:Sum=0
Fori=1Ton
Ifscore(i)>score(maxid)Thenmaxid=i
Ifscore(i)<score(minid)Thenminid=i
Sum=Sum+score(i)
Nexti
Avg=Sum/n

Print"最高分學號="&sno(maxid)&"成績="&score(maxid)
Print"最低分學號="&sno(minid)&"成績="&score(minid)
Print"超過平均分學生列表-------------"
Fori=1Ton
Ifscore(i)>AvgThen
Printsno(i),score(i)
EndIf
Nexti
EndSub

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919