Assume s, a, b, c are declared as integers, and a, c have been assigned values ( c>0 ),s=a;for(b=1; b<=c; b++)s=s+1;Which one of the following is equal to the above code?
A: s=a+b;
B: s=a+c;
C: s=s+c;
D: s=b+c;
A: s=a+b;
B: s=a+c;
C: s=s+c;
D: s=b+c;
举一反三
- 教材P89习题4 一、选择题 5. A: s=a+b; B: s=a+c; C: s=s+c; D: s=b+c;
- 如果c是大于1的正整数,与以下程序段功能相等的赋值语句是( )。 A: s=b+c; B: s=s+c; C: s=a+b; D: s=a+c;
- 3.11下面()语句与下列if语句等价。if(a>;b) s=a+b;elses=a-b; A: switch(a>;b) { case 1:s=a+b;break; case 0:s=a-b;break; } B: switch(a>;b) { case 1:s=a+b; case 0:s=a-b; } C: switch(a<;b) { case 1:s=a-b; case 0:s=a+b; } D: switch(a<;b) { case 1:s=a-b;break; case 0:s=a+b;break; }
- 以下程序会报错的是( )。 A: s = ["a", "b", "c"] print(s[1]) B: s = ("a", "b", "c") print(s[1]) C: s = {"a", "b", "c"} print(s[1]) D: s = {0:"a", 1:"b", 2:"c"} print(s[1])
- 异步电动机处于电动机状态,发电机状态和电磁制动状态下的转差率s分别为()。 A: 0<s<1, s<0, s>1 B: −1<s<1, s<−1, s>1 C: 0<s<1, s>1, s<0 D: −1