#G072. GESP level3 程序阅读题
GESP level3 程序阅读题
GESP level3 - 程序阅读题
- 下列代码中,输出结果是( )
{{ select(1) }}#include using namespace std; int main(){ double a=0.9; double b=1.0; if(((b-a)==0.1)) { cout<<"Equal"<<endl; } else{ cout<<"Not equal"<<endl; } }
- Equal
- Not equal
- 程序不能正确执行
- 没有输出
- 关于计算机中的编码,下列说法中正确的是()
{{ select(2) }}A. 机器数的形式值和真值是一致的 B. 原码就是符号位加上真值 C. 机器数是带符号的 D. [-1]=[1000 0001]原=[1111 1111]反
- A
- B
- C
- D
- 下列代码实现的是( )
{{ select(3) }}void Swap(int &a, int &b) { if (a != b) { a ^= b; b ^= a; a ^= b; } }
- a和b的异或
- a和b的同或
- a和b的值交换
- a和b的高低位互换
- a&~1运算实现的是( )
{{ select(4) }}A. 使a的最低位为1 B. 使a的最高位为1 C. 使a的最低位为0 D. 使a的最高位为0
- A
- B
- C
- D
- 下列程序中,result和result2输出分别是( )
{{ select(5) }}long a = 123; int b = 1; long result = a & b; cout<<result<<endl; long a2 = -123; unsigned int b2 = -1; long result2 = a2 & b2; cout<<result2<<endl;
- 123 -1
- 123 -123
- 1 -1
- 1 -123
- 下面的程序中,会输出( )
{{ select(6) }}int a[10]={1,2,3,4,5,6,7,8,9,10}; cout<<a[10]<<endl;
- 1
- 0
- 10
- 不确定的值
- 下列程序输出的是()
{{ select(7) }}string str = "Hello,CHAD"; cout << str.find("A") << '\n';
- 9
- 8
- 7
- 6
- 下面C++代码执行后的输出是( )
{{ select(8) }}int temp=0; for(int i=1;i<7;i++) for(int j=1;j<5;j++) if(i/j==2) temp++; cout<<temp<<endl;
- 10
- 8
- 4
- 3
- 执行下面C++代码后输出的是( )
{{ select(9) }}string str("chen"); int x=str.length(); cout<<x<<endl;
- 4
- 3
- 2
- 5
- 下面C++代码执行后的输出是( )
{{ select(10) }}char ch[10]={'1'}; cout<<ch[2]<<endl;
- 0
- 1
- 输出空格
- 什么也不输出
- 下面C++代码用于统计每种字符出现的次数,当输出为3时,横线上不能填入的代码是( )
{{ select(11) }}string str="GESP is a good programming test"; int x=0; for(int i=0;i<str.length();i++) if(______) x++; cout<<x<<endl;
- str[i]=='o'
- str[i]=='a'+14
- str[i]==115
- str[i]==111
- 执行下面C++代码后输出的是( )
{{ select(12) }}string str="chen"; int x=str.length(); for(int i=0;i<=x;i++) temp++; cout<<temp<<endl;
- 4
- 2
- 5
- 3
- 如果数组定义为long long array[] = {3, 5, 7, 2}; ,则数组array 占用的字节数为( ) {{ select(13) }}
- 32
- 16
- 8
- 4
- 一个数组定义为double array[3]; ,则可合理访问这个数组的元素的下标最大为( ) {{ select(14) }}
- 2
- 3
- 23
- 24
- 下列关于C++语言中数组的叙述,不正确的是( )
{{ select(15) }}A. 可以定义0 个元素的数组 B. 不能定义-1 个元素的数组 C. 数组下标越界访问会产生编译错误 D. 程序运行时发生数组下标的越界访问,程序依然可能正常结束
- A
- B
- C
- D
- 在下列代码的横线处填写( ),可以使得输出是“20 10”
{{ select(16) }}#include using namespace std; int main(){ int a=10,b=20; a=(a<<8)|b; ____//在此处填入代码 cout<<a<<" "<<b<<endl; return0; }
- a = a >> 8; b = a & 0xff
- b = a >> 8; a = a & 0xff;
- a = b; b = a & 0xff;
- b = a; a = b;
- 执行下面C++代码后输出的第一个数是( )
{{ select(17) }}int main(){ int a[20],i; for(i = 0; i < 20; i++) a[i] = i+1; for( ; i > 0; i--) cout << a[i-1] << " "; }
- 20
- 19
- 1
- 不确定
- 已知字符'0' 的ASCII编码的十进制表示为48,则执行下面C++代码后,输出是( )
{{ select(18) }}int main() { string s="316"; int n=s.length(); int x=0; for(int i = 0; i < n; i++) x += s[i]; cout << x << endl; }
- 10
- 58
- 154
- 316
- 下面C++代码执行后数组中大于0的数的特征是( )
{{ select(19) }}int main() { int a[20],i; for(i = 0; i < 20; i++) a[i] = i+1; for(int i = 0; i < 20; i++) if((a[i]%2)&&(a[i]%3)) a[i] = 0; for(i = 0; i < 20; i++) if(a[i]) cout << a[i] << " "; }
- 2的倍数
- 3的倍数
- 能被2或3整除的数
- 能被2和3同时整除的数
- 在下列代码的横线处填写( ),可以使得输出是“7”
{{ select(20) }}#include using namespace std; int main() { int array[5] = {3,7,5,2,4}; int max = 0; for(int i=0; i<5; i++) if(_____) max = array[i]; cout << max << endl; }
- max > array[i]
- max < array[i]
- max = array[i]
- 以上均不对
- 下列程序输出的是( )
{{ select(21) }}string ch="hello"; if(ch[5]NULL) { cout<<"right"<<endl; } else if (ch[5]'\0') { cout<<"wrong"<<endl; } else { cout<<"hello"<<endl; }
- right
- wrong
- hello
- 不能正确执行
- 下列程序最后输出的是()
{{ select(22) }}int a=65; cout<<tolower(a)<<endl;
- 65
- A
- a
- 97
- 在下列代码的横线处填写( ),可以使得输出不是“31”
{{ select(23) }}#include using namespace std; int main(){ int array[5] = {1,2,4,8,16}; int res=0; for(int i=0;i<5;i++) ______; cout<<res<<endl; }
- res = res + array[i]
- res = res & array[i]
- res = res | array[i]
- res = res ^ array[i]