一道VB的编程题(1加到100)

请分别用FOR和Do...Loop循环语句计算1到100之和
2025-01-02 02:49:58
推荐回答(3个)
回答1:

Do While I <= 100
Sum = Sum + I
I = I + 1
Loop
Print Sum
Do
Sum = Sum + I
I = I + 1
Loop Until I > 100
Print Sum
For I = 1 To 100
Sum = Sum + I
Next
Print Sum

回答2:

Do While I <= 100
Sum = Sum + I
I = I + 1
Loop
Print Sum

Do
Sum = Sum + I
I = I + 1
Loop Until I > 100
Print Sum

For I = 1 To 100
Sum = Sum + I
Next
Print Sum

回答3:

不用循环?一个个加么?我没笑←_←