下列程序执行后,sum的结果是________。Dim sum As IntegerFor i = 1 To 4 Step 2 For j = 1 To i Step 2 sum += j NextNext
A: 6
B: 9
C: 5
D: 7
A: 6
B: 9
C: 5
D: 7
举一反三
- 在下列程序段中,不能计算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
- 以下程序的运行结果是( <br/>)。 #includevoid main() { int i,j,sum=0; for(i=1;i<=2;i++) { for(j=1;j<=2;j++) sum+=i*j; } printf("%d",sum); } A: 3 B: 5 C: 7 D: 9
- 执行以下程序段后sum的值?int i,j,sum=0;for(i=1;i<=5;i++){ for(j=1;j<=5;j+=2) sum=sum+1;} A: 25 B: 15 C: 50 D: 5
- 正确定义了i,j,sum三个变量,下列程序片段运行结束后sum的值是( )for(i=2;i<7;i++){ sum=1; for(j=i;j<7;j++) sum=sum+j; } A: 48 B: 49 C: 1 D: 7
- 以下程序的运行结果是()。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