# 题目哈: [(单科成绩-60)/10+1]*单科学分 求和后再除以总学分

2023-01-12 21:17:30

Option Base 1
Const num = 10
Dim a(num) As Single, b(num) As Single, c(num) As Single
Dim x As Single, m As Single
Dim sum As Single, i As Integer

Private Sub Command1_Click()

sum = 0
For i = 1 To num
c(i) = ((a(i) - 60) / 10 + 1) * b(i)
sum = sum + c(i)
Next i

x = sum / m
Print "Text00.Text"; x
End Sub

a(1) = Val("Text1.Text") '各科成绩
a(2) = Val("Text2.Text")
a(3) = Val("Text3.Text")
a(4) = Val("Text4.Text")
a(5) = Val("Text5.Text")
a(6) = Val("Text6.Text")
a(7) = Val("Text7.Text")
a(8) = Val("Text8.Text")
a(9) = Val("Text9.Text")
a(10) = Val("Text10.Text")
b(1) = Val("Text11.Text") '各科学分
b(2) = Val("Text12.Text")
b(3) = Val("Text13.Text")
b(4) = Val("Text14.Text")
b(5) = Val("Text15.Text")
b(6) = Val("Text16.Text")
b(7) = Val("Text17.Text")
b(8) = Val("Text18.Text")
b(9) = Val("Text19.Text")
b(10) = Val("Text20.Text")
m = Val(Text0.Text) '总学分
End Sub

## 3 回答

TA贡献1619条经验 获得超2个赞

Option Explicit

Option Base 1
Const num = 10
Dim a(num) As Single, b(num) As Single, c(num) As Single
Dim x As Single, m As Single
Dim sum As Single, i As Integer

Private Sub Command1_Click()
sum = 0
For i = 1 To num
c(i) = ((a(i) - 60) / 10 + 1) * b(i)
sum = sum + c(i)
Next i

x = sum / m
Print "Text00.Text"; x
End Sub

a(1) = Val(Text1.Text) '各科成绩
a(2) = Val(Text2.Text)
a(3) = Val(Text3.Text)
a(4) = Val(Text4.Text)
a(5) = Val(Text5.Text)
a(6) = Val(Text6.Text)
a(7) = Val(Text7.Text)
a(8) = Val(Text8.Text)
a(9) = Val(Text9.Text)
a(10) = Val(Text10.Text)
b(1) = Val(Text11.Text) '各科学分
b(2) = Val(Text12.Text)
b(3) = Val(Text13.Text)
b(4) = Val(Text14.Text)
b(5) = Val(Text15.Text)
b(6) = Val(Text16.Text)
b(7) = Val(Text17.Text)
b(8) = Val(Text18.Text)
b(9) = Val(Text19.Text)
b(10) = Val(Text20.Text)
m = Val(Text0.Text) '总学分
End Sub

============================================

Option Explicit

Option Base 1
Const Total = 10

Private Sub Command1_Click()
Dim Sum As Single, Score(Total) As Single, Credit(Total) As Single
Dim i As Integer, SumCredit As Integer
For i = 1 To Total
Score(i) = (Val(Text1(i - 1).Text) - 60) / 10 + 1
Credit(i) = Val(Text1(i + Total - 1).Text)
Sum = Sum + Score(i) * Credit(i)
SumCredit = SumCredit + Credit(i)
Next i

MsgBox "平均学分:" & Format(Sum / SumCredit, "0.00")
End Sub

Dim i As Integer
Text1(0).Text = 90
For i = 0 To Total - 1
If i <> 0 Then
Text1(i).Left = Text1(0).Left
Text1(i).Top = Text1(i - 1).Top + Text1(0).Height + 100
Text1(i).Visible = True
Text1(i).Text = Int(Rnd * 60) + 35
End If
Text1(i + Total).Left = Text1(0).Left + Text1(0).Width + 400
Text1(i + Total).Top = Text1(i).Top
Text1(i + Total).Visible = True
Text1(i + Total).Text = Int(Rnd * 5) + 1
Next
End Sub
=========================================

c(i) = ((a(i) - 60) / 10 + 1) * b(i)

ITMISS

TA贡献1577条经验 获得超8个赞

Option Base 1
Const num = 10
Dim a(num) As Single, b(num) As Single, c(num) As Single
Dim x As Single, m As Single
Dim sum As Single, i As Integer

Private Sub Command1_Click()
sum = 0
m=0
For i = 1 To num
c(i) = ((a(i) - 60) / 10 + 1) * b(i)
sum = sum + c(i)
m=m+b(i)
Next i

if m>0
x = sum / m
Print "Text00.Text"; x
end if
End Sub

a(1) = Val(Text1.Text) '各科成绩
a(2) = Val(Text2.Text)
a(3) = Val(Text3.Text)
a(4) = Val(Text4.Text)
a(5) = Val(Text5.Text)
a(6) = Val(Text6.Text)
a(7) = Val(Text7.Text)
a(8) = Val(Text8.Text)
a(9) = Val(Text9.Text)
a(10) = Val(Text10.Text)
b(1) = Val(Text11.Text) '各科学分
b(2) = Val(Text12.Text)
b(3) = Val(Text13.Text)
b(4) = Val(Text14.Text)
b(5) = Val(Text15.Text)
b(6) = Val(Text16.Text)
b(7) = Val(Text17.Text)
b(8) = Val(Text18.Text)
b(9) = Val(Text19.Text)
b(10) = Val(Text20.Text)
End Sub

qq_笑_17

TA贡献1568条经验 获得超7个赞

• 3 回答
• 0 关注
• 7 浏览

0/150