• 2021-04-14
    【单选题】已知如下多元素变量 执行下列程序,回答问题:上述程序执行完成后,Sum1和Sum2的值分别为_____。 int I = 3 ,J; int Sum1=0 ,Sum2=0; For J=1 to 4 Step 1 { Sum1 = Sum1 + M[I][J] ; Sum2 = Sum2 + M[J][I] ; }
    A. 105 ,149 B. 576 , 576 C. 149 ,105 D. 136 , 175
  • 149 ,105

    内容

    • 0

      执行以下程序段后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

    • 1

      中国大学MOOC: 已知如下多元素变量。 【图片】执行下列程序,执行完成后,Sum1和Sum2的值分别为_____。(10)intJ;(20)intSum1=0,Sum2=0;(30)ForJ=1to4Step1(40){Sum1=Sum1+M[J][J];(50)Sum2=Sum2+M[5-J][5-J];}

    • 2

      在下列程序段中,不能计算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

    • 3

      下面程序用来计算1+1/2!+1/3!+…1/10!,请完善程序。#includeintmain(){inti,j;sum=0,fac;for(i=1;i<=10;i++){fac=1;for(j=1;j<=i;j++)fac=fac*j;sum=sum+1/fac;}printf("%f",sum);return0;}

    • 4

      和下面代码执行结束后,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: 上述全对