VB:求出n个学生一门课程中的最高成绩、最低成绩及高于平均成绩的人数

求出n个学生一门课程中的最高成绩、最低成绩及高于平均成绩的人数
用VB编程~谢谢!

先用一个循环把N个学生的成绩装入数组a(n)中,然后在用一个for循环把最高分和最低分找出,同时把这门课的平均分求出,最后用一个for循环把高于平均分的人数求出
部分代码:

我这里就假如是在文件中读出了的(d:\student.txt里面放的学生的成绩)依具体情况而定
open "d:\student.txt" for input as #1
do while not eof(1)
Input #1, str
a(n)=val(str)
n=n+1
loop

for x=0 to n-1 '求平均分,最高分,最低分
sum=sum+a(x) '求总分
if top(初始为a(0)或a(n)都可以)<a(x) then
top=a(x)
end if
if lowe(初始为a(0)或a(n)都可以)>a(x) then
lowe=a(x)
end if
next
avg=sum/n '平均分

for x=0 to n-1 then '求高于平均分的人数啊
if a(x)>avg then
y=y+1 '用在存放高于平均分的人数
end if
next
...............
.............
hehe
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-08-04
sub sub1(list(),maxF,minF,counts)'maxF返回最高成绩minF返回最低成绩counts返回高于的人数
dim sum,people
maxF=0:minF=100
people=ubound(list)-lbound(list)+1
for i =lbound(list) to ubound(list)
if list(i)>maxF then maxF=list(i)
if list(i)<minF then minF=list(i)
sum=sum+list(i)
next i
sum=sum/people
for i =lbound(list) to ubound(list)
if list(i)>sum then counts=oounts+1
next i
end sub
第2个回答  2019-06-19
sub
sub1(list(),maxF,minF,counts)'maxF返回最高成绩minF返回最低成绩counts返回高于的人数
dim
sum,people
maxF=0:minF=100
people=ubound(list)-lbound(list)+1
for
i
=lbound(list)
to
ubound(list)
if
list(i)>maxF
then
maxF=list(i)
if
list(i)<minF
then
minF=list(i)
sum=sum+list(i)
next
i
sum=sum/people
for
i
=lbound(list)
to
ubound(list)
if
list(i)>sum
then
counts=oounts+1
next
i
end
sub

VB:求出n个学生一门课程中的最高成绩、最低成绩及高于平均成绩的...
do while not eof(1)Input #1, str a(n)=val(str)n=n+1 loop for x=0 to n-1 '求平均分,最高分,最低分 sum=sum+a(x) '求总分 if top(初始为a(0)或a(n)都可以)a(x) then lowe=a(x)end if next avg=sum\/n '平均分 for x=0 to n-1 then '求高于平均分...

...门课程的最好成绩、最低成绩及高于平均成绩的人数?
cout<<"最好成绩是:"<<scores[n-1]<<",最差成绩是:"<<scores[0]<<",高于平均成绩的有:"<<count<<"人!"<<endl;}

vb编写应用程序输入若干学生一门课程的成绩,统计平均成绩,及格和不及格...
Dim a As Double = 0 '总成绩 Dim b As Double = 0 '平均成绩 Dim c As Integer = 0 '及格人数 Dim d As Integer = 0 '不及格人数 '定义一个变量,输入人数 Dim i As Integer = InputBox("请输入人数:", "提示", 5) '循环填入每个人的成绩 For j = 1 ...

vb题,求编程 输入若干个成绩,求出其平均分,然后将成绩大于平均分的学...
a(i) = Val(InputBox("请输入第 " & i & " 个成绩:"))s = s + a(i)Next i For i = 1 To n - 1 For j = 1 To n - i If a(j) < a(j + 1) Then t = a(j): a(j) = a(j + 1): a(j + 1) = t End If Next j Next i av = s \/ n i = 1 Do...

怎么用VB做出成绩排名表?
>=90人数:B14=SUM(COUNTIF(B3:B12,">=90"),COUNTIF(D3:D12,">=90"))及格率:B15=TEXT(SUM(COUNTIF(B3:B12,">=60"),COUNTIF(D3:D12,">=60"))\/COUNT(B3:B12,D3:D12),"0.0%")最高分:=MAX(B3:B12,D3:D12)如果学号都大於成绩或学号为文本格式,<60人数可简化:B13=...

VB输入N个学生的学号和成绩,打印出成绩最高者的学号和成绩
End If End Sub Private Sub Command2_Click()Dim t As stu Picture2.Cls Picture2.AutoRedraw = True imax = 0 For N = 1 To i - 1 If a(N).fs > a(imax).fs Then imax = N Next N Picture2.Print "成绩最高分是学号"; a(m).id; Spc(2); "分数为"; a(m).fs ...

编写一个程序,输入N个学生的成绩,输出高于平均成绩的学生的学号和成绩...
VB:private command1_click()dim a(10) as single for i=1 to 10 a(i)=inputbox("输入第"+i+"个数:")sum=sum+a(i)next i sum=sum\/10 for i=1 to 10 if i>sum then print a(i);next i end sub

求从键盘输个学生的成绩,计算平均分且输出低于平均分的人数的vb代码
Private Sub Form_Load() Dim l As Integer, r As Integer Dim c1 As Integer, c2 As Integer, cp As Single Do While MsgBox("我要输入成绩", vbOKCancel, "还有学生?") = vbOK r = r + 1 c1 = Val(InputBox("请输入""语文""成绩", "学生" & r, 0)) c2 = Val(...

vb编程用 for循环 输入五个学生分数(inputbox函数) 求它们的平均分及...
Dim s As Single, k As Single, n As Integer, i As IntegerFor i = 1 To 5 k = Val(InputBox("请输入第" & i & "个学生的分数")) s = s + k If k < 60 Then n = n + 1NextMsgBox "平均分为" & s \/ 5 & ",不及格人数" & n ...

VB输入几个学生成绩,统计及格人数,不及格人数和平均分
i = 1 To rs cj = InputBox("输入成绩")If cj >= 60 Then jg = jg + 1 If cj < 60 Then bjg = bjg + 1 zcj = zcj + cj Next i Label1.Caption = "及格人数为:" & jg Label2.Caption = "不及格人数为:" & bjg Label3.Caption = "平均分" & zcj \/ rs End Sub ...

相似回答