java输出偶数_Java怎么编程输出1-100间的偶数?

展开全部

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值