下列代码样例中,哪个存在错误:()
A: forfilename in $(ls)do cat $filenamedone
B: for((i=0;i<10;i++))do echo $idone
C: x=1sum=0while [ $x -le 10 ]do let sum=sum+$x let x=x+1doneecho\ $sum
D: for $i in 1 2 3 4 5do echo $idone
A: forfilename in $(ls)do cat $filenamedone
B: for((i=0;i<10;i++))do echo $idone
C: x=1sum=0while [ $x -le 10 ]do let sum=sum+$x let x=x+1doneecho\ $sum
D: for $i in 1 2 3 4 5do echo $idone
举一反三
- 下列代码样例中,哪个存在错误:() A: for filename in $(ls) do cat $filename done B: for((i=0;i<10;i++)) do echo $i done C: x=1 sum=0 while [ $x -le 10 ] do let sum=sum+$x let x=x+1 done echo\ $sum D: for $i in 1 2 3 4 5 do echo $i done
- 下面代码的运行结果为sum=()。 [?php $sum=0; for ($i=1;$i<=10;$i++){ if($i]5)break; $sum=$sum+$i; } echo"sum=".$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: 上述全对
- 和下面代码执行结束后,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: 上述全对
- 执行下面程序段后,sum的值是( )。int i=0,sum=1; do{ sum+=i++; }while(i<5);