下面语句的执行结果是sum <- 0for(i in 1:100)sum = sum + iprint(sum)
A: 5050
B: 5000
C: 5020
D: 5045
A: 5050
B: 5000
C: 5020
D: 5045
举一反三
- 下列循环的执行结果是( ).sum = 0for i in... = sum + iprint(sum)
- 下面程序段的运行结果是____。s = 1: sum = 0For i = 1 To 4 s = s * i sum = sum + sNext iPrint sum A: 24 B: 33 C: 10 D: 30
- 程序: clear sum=0; for i=1:100 sum=sum+i; end sum 运行后结果sum=( ) A: 5010 B: 5030 C: 5050 D: 5070
- sum=0for i in range(0,100): if i%2==0: sum-=i else: sum+=iprint(sum) A: -50 B: 49 C: 50 D: -49
- 在下列程序段中,不能计算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