隨機產生20個學生的成績
『壹』 隨機產生20個學生的成績(整數),統計各分數段人數。即0~59、60~69、70~79、80~89、90~100,
Dim sj(19), i As Integer
Private Sub command1_Click()
Dim sj(19), i As Integer
For i = 0 To 19
sj(i) = Int(Rnd * 101)
Picture1.Print sj(i);
If (i + 1) Mod 4 = 0 Then Picture1.Print
Next i
End Sub
Private Sub Command2_Click()
Dim a, b, c, d, e As Integer, s(9), sj(19), i As Integer
For i = 0 To 19
sj(i) = Int(Rnd * 101)
Picture1.Print "";
If (i + 1) Mod 4 = 0 Then Print ""
Next i
a = 0
b = 0
c = 0
d = 0
e = 0
For i = 0 To 19
If sj(i) <= 59 Then a = a + 1
Next i
For i = 0 To 19
If sj(i) >= 60 And sj(i) <= 69 Then b = b + 1
Next i
For i = 0 To 19
If sj(i) >= 70 And sj(i) <= 79 Then c = c + 1
Next i
For i = 0 To 19
If sj(i) >= 80 And sj(i) <= 89 Then d = d + 1
Next i
For i = 0 To 19
If sj(i) >= 90 And sj(i) <= 100 Then e = e + 1
Next i
Picture2.Print "s(5)"; a; Chr(13);
Picture2.Print "s(6); b; ; Chr(13);
Picture2.Print "s(7); c; "??"; Chr(13); "s(8)"; d; ; Chr(13); "s(9)"; e;
End Sub
『貳』 [vb]隨機產生20個學生的成績,統計各分數段人數。
Option Explicit
Dim d(1 To 20) As Integer
Private Sub Command1_Click()
Dim i As Integer
Picture1.Cls
For i = 1 To 20
d(i) = Int(Rnd() * 100) + 1
Picture1.Print Format(d(i), " 0");
If i Mod 4 = 0 Then Picture1.Print
Next 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
『叄』 foxpro程序 隨機產生20個學生成績,求出他們的平均成績,並統計出高於平均成績的學生數
clear
n=20
dimes(n)
fori=1ton
s(i)=int(rand()*100)+1
endfor
fori=1ton
?s(i)
endfor
x=0
fori=1ton
x=x+s(i)
endfor
y=int(x/n)
?'平均成績=',y
m=0
fori=1ton
ifs(i)>y
m=m+1
endif
endfor
?'高於平均成績人版數權=',m
fori=1ton-1
forj=1ton-i
ifs(j)>s(j+1)
t=s(j)
s(j)=s(j+1)
s(j+1)=t
endif
endfor
endfor
fori=1ton
?s(i)
endfor
return
『肆』 vb編程:隨機產生20個學生課程分數並顯示,統計各分數段人數,顯示統計結果
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 Then
a(3) = a(3) + 1
ElseIf iScore >= 70 Then
a(2) = a(2) + 1
ElseIf iScore >= 60 Then
a(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
『伍』 java題,用類方法隨機生成20名學生成績成績並計算平均分和總分,按總分排序
『陸』 excel表格 隨機產生20或者25 excel表格 需要隨機生成學生成績,20分或者25分
輸入
=CHOOSE(RANDBETWEEN(1,2),20,25)
詳見附圖
『柒』 編程 隨機生成20個學生的成績(60分—100分)(用數組存放數據) 輸出最高分和最低分,平均分 利用數組
#include<stdio.h>
main()
{ double a[20],s=0.0;
int i ,j ,t;
for(i=0;i<20;i++)
{ scanf(a[i]);
s=s+a[i];
}
priintf(''平均分是%f '',s/20);
for(i=0;i<19;i++)
for(j=i+1;j<20;j++)
{ if(a[i]>a[j])
{ t=a[i];
a[i]=a[j];
a[j]=t;
}
}
printf("最大值為專%f,最小屬值為%f",a[19],a[0]);
}
『捌』 VB設計:隨機產生20個學生的成績,並顯示.統計各分數段人數,即50~59, 60~69, 70~79,80-89,90-100。
Option Explicit
Private Sub showScore()
Dim score(1 To 20) As Integer
Dim an(1 To 5) As Integer
Dim i As Integer
Randomize
For i = 1 To UBound(score)
score(i) = CInt(Rnd * 100)
Select Case score(i)
Case 0 To 59
an(1) = an(1) + 1
Case 60 To 69
an(2) = an(2) + 1
Case 70 To 79
an(3) = an(3) + 1
Case 80 To 89
an(4) = an(4) + 1
Case 90 To 100
an(5) = an(5) + 1
End Select
Next
For i = 1 To 5
Select Case i
Case 1
Print "0 - 59 :",
Case 2
Print "60 - 69:",
Case 3
Print "70 - 79:",
Case 4
Print "80 - 89:",
Case 5
Print "90 - 100:",
End Select
Print CStr(an(i))
Next
End Sub
Private Sub Form_Click()
Cls
showScore
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
showScore
End Sub
『玖』 VB程序,隨機產生20個學生的成績,並顯示.統計各分數段人數,即0~59,60~69,70~79,8
Private Sub Command1_Click()
Dim a(20) As Integer
Cls
c1 = 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 Print
Next 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 Integer
Cls
Randomize
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 Print
Next 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
『拾』 [vb]隨機產生20個學生的成績,統計各分數段人數。
Option Explicit
Dim d(1 To 20) As Integer
Private Sub Command1_Click()
Dim i As Integer
Picture1.Cls
For i = 1 To 20
d(i) = Int(Rnd() * 100) + 1
Picture1.Print Format(d(i), " 0");
If i Mod 4 = 0 Then Picture1.Print
Next 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~:"; 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