在下列程序段中,不能计算1到100之间奇数之和的是__________。
A: Dim sum As Integer sum = 0 For i = 1 To 100 Step 2 sum = sum + i Next
B: Dim sum As Integer sum = 0 For i = 1 To 100 If i Mod 2 <> 0 Then sum = sum + i Next
C: Dim sum As Integer sum = 0 For i = 1 To 99 sum = sum + i Next
D: Dim sum As Integer sum = 0 For i = 100 To 1 Step -1 If i Mod 2 <> 0 Then sum = sum + i Next
A: Dim sum As Integer sum = 0 For i = 1 To 100 Step 2 sum = sum + i Next
B: Dim sum As Integer sum = 0 For i = 1 To 100 If i Mod 2 <> 0 Then sum = sum + i Next
C: Dim sum As Integer sum = 0 For i = 1 To 99 sum = sum + i Next
D: Dim sum As Integer sum = 0 For i = 100 To 1 Step -1 If i Mod 2 <> 0 Then sum = sum + i Next
举一反三
- $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______。 2、 $sum = 0; for($i=1;$i<=100;;++$i){ if($i%2==0){ continue; } $sum += $i; } echo '$sum ='.$sum; echo输出值为_______
- 执行循环后,两变量 I, Sum 分别是: Dim I As Short = 1 Dim Sum As Long = 0 Do While I <= 5 Sum += I I = I + 2 Loop
- 看程序,写结果 main() { int i,sum=0; i = 1; while (i < 100) { sum = sum + i; i++; } printf("%d",sum); }
- 智慧职教: 看程序,写结果main() { int i,sum=0; i = 1; do { sum = sum +2; i++; } while (i<100); printf("%d",sum); }
- 以下四个选项中和下面代码功能相同的是( )。(选择一项) int i = 1; int sum = 0; while (i <= 100) { if (i % 2 == 0) sum = sum + i; i++; } A: for (int x =1; x<=100;x++){ sum=sum+x;} B: for (int x =0; x<=100;x+=2){ sum=sum+x;} C: for (int x =1; x<=100;x+=2){ sum=sum+x;} D: 上述全对