Private Sub Command1_Click()
Dim i, sum1, sum2 As Integer
sum1 = 0
sum2 = 0
For i = 1 To 100
If i Mod 2 = 1 Then
sum1 = sum1 + i
Else
sum2 = sum2 + i
End If
Next i
Print "奇数和为" & sum1
Print "偶数和为" & sum2
End Sub
j=0// 这个是放奇数和的
i=0
o=0//这个是放偶数和的
for i=1 to 100
if 1\2=0 then o=o+i
else j=j+i
next i
print "ji shu shi:",j
print "o shu shi:",j
end
有必要这样写么,只要一个循环足够了
剩下的就是5050-就可以了