编写求1到100之间奇数的和。用Vb语言。 10
2个回答
展开全部
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
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
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询