展开全部
for(int i=0;i;i+){
if(i%2=0){
System.out.println(i);}
}
一、按钮“e68a8462616964757a686964616f31333365646232求2到100之间的偶数和”代码如下:
Private Sub Command1_Click()Dim i As IntegerDim s As Integers = 0For i = 2 To 100 Step 2 s = s + iNext iPrint "2到100的所有偶数和是:"; sEnd Sub
二、按钮“方法2”代码如下:
Private Sub Command2_Click()Dim i As IntegerDim s As Integers = 0For i = 2 To 100If i Mod 2 = 0 Then s = s + iEnd IfNext iPrint "2到100的所有偶数和是:"; sEnd Sub
三、按钮“方法3”代码如下:
Private Sub Command3_Click()Dim i As IntegerDim s As Integers = 0i = 2DoIf i Mod 2 = 0 Then s = s + iEnd Ifi = i + 1Loop Until i > 100Print "2到100的所有偶数和是:"; sEnd Sub
四、按钮“方法4”代码如下:
Private Sub Command4_Click()Dim i As IntegerDim s As Integers = 0i = 2Dos = s + ii = i + 2Loop Until i > 100Print "2到100的所有偶数和是:"; sEnd SubPrivate Sub Command2_Click()Dim i, sum1, sum2 As Integersum1 = 0sum2 = 0For i = 1 To 100If i Mod 2 = 1 Thensum1 = sum1 + iElsesum2 = sum2 + iEnd IfNext iPrint "奇数和为" & sum1Print "偶数和为" & sum2End Sub