展开全部
Private Sub Form_click()
jsum = 0: osum = 0
For i = 10 To 700
If i Mod 2 = 0 Then
osum = osum + i
Else
jsum = jsum + i
End If
Next i
Print "奇数和是:"; jsum
Print "偶数和是:"; osum
End Sub
追问
大神能否允许我再问几道题
编程求1--1000之间所有能被7整除之和
编程求1--1000之间是5的倍数的自然数之和
编程求在100--900之间所有能被5除余3,被7除余5的数之和
追答
Private Sub Form_click()
Sum = 0
For i = 1 To 1000
If i Mod 7 = 0 Then
Sum = Sum + i
End If
Next i
Print "1-1000之间能被7整除之和是:" & Sum
Sum = 0
For i = 1 To 1000
If i Mod 5 = 0 Then
Sum = Sum + i
End If
Next i
Print "1-1000之间是5的倍数的自然数之和:" & Sum
Sum = 0
For i = 100 To 1000
If i Mod 5 = 3 And i Mod 7 = 5 Then
Sum = Sum + i
End If
Next i
Print "100-1000之间之间所有能被5除余3,被7除余5的数之和" & Sum
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询