1. 以下求10以内的所有奇数之和的值是() sum = 0 i= 1 while i < 10: if i % 2 !=0: sum += i i ++ print (sum)
举一反三
- $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输出值为_______
- 以下程序的运行结果是()。main(){ int i=1,sum=0; while(i<;10) sum=sum+1;i++; printf("i=%d,sum=%d",i,sum);} A: 程序死循环 B: A:i=10,sum=9 C: B:i=9,sum=9 D: C:i=2,sum=1
- 以下程序的运行结果是(). main() { int i=1,sum=0; while(i<10) sum=sum+1;i++; printf("i=%d,sum=%d",i,sum); } A: i=10,sum=9 B: i=9,sum=9 C: i=2,sum=1 D: 运行出现错误
- 在下列程序段中,不能计算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
- 求10以内能被3整除不能被2整除的整数之和 以下程序运行后,sum 的值为:_(1)____ int i,sum; sum=0; for(i=2;i<;=10;i++) { if(____(2)____) sum=sum+i; }