ImageVerifierCode 换一换
格式:DOCX , 页数:20 ,大小:33.19KB ,
资源ID:23386755      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/23386755.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(华南理工大学《高级语言程序设计C》期末练习题.docx)为本站会员(b****9)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

华南理工大学《高级语言程序设计C》期末练习题.docx

1、华南理工大学高级语言程序设计C 期末练习题 高级语言程序设计(C+)练习题一单项选择题1.用C+语言编制的源程序要变为目标程序必须要经过( )。(a) 解释 (b) 汇编 (c) 编辑 (d) 编译2. 执行C+程序时出现的“溢出”错误属于( )错误。(a) 编译 (b) 连接 (c) 运行 (d) 逻辑3. 按C+标识符的语法规定,合法的标识符是( )。(a) abc (b) new (c) (d) age 4计算表达式x=a=4,b=x+ 后,变量x,a,b的值分别是:( ) (a) 4,4,4 (b) 4,4,5 (c) 4,5,5 (d) 5,4,4 5表达式1/2*2.0的值是:(

2、) (a) 2 (b) 1 (c) 0.5 (d) 06下列选项中,( )不能交换变量a和b的值。(a) t=b; b=a; a=t; (b) a=a+b; b=a-b; a=ab;(c) t=a; a=b; b=t; (d) a=b; b=a; 7有以下变量说明,下面正确的语句是( )。 int a=10, b; int &pa=a, &pb=b; (a) &pb = a; (b) pb = pa; (c) pb = &pa; (d) *pb = *pa;8执行下面语句序列后,a和b的值分别为( )。int a = 5 , b = 3 , t ;int &ra = a ;int &rb =

3、b ;t = ra ; ra = rb ; rb = t ;(a) 3和3 (b) 3和5 (c) 5和3 (d) 5和59.设X为整型变量,不能正确表达数学关系 1X5 的C+逻辑表达式是( )。(a) 1 X 5 (b) X=2|X=3|X=4(c) 1X&X5 (d) !(X=5)10. 设 int a=1, b=2, c=3, d=4; 则以下条件表达式的值为( )。ab ? a : cd ? c : d(a) 1 (b) 2 (c) 3 (d) 4 11. 以下逗号表达式的值为( )。( a = 5/2, a*5 ), a*5 (a) 2 (b) 10 (c) 15 (d) 5012

4、. 设 int x=1, y=3 , 能正确表示代数式3x|x-y|的C+表达式是( )。 (a)abs(x-y)*3*x (b)3x(abs(x-y) (c) 3x|(x-y) (d)3*x*(x-y)| 3*x*(y-x)13已知 int i=0, x=1, y=0 ; 在下列选项使i的值变成1的语句是( )。(a) if( x & y ) i+ ; (b) if( x = y ) i+ ;(c) if( x | y ) i+ ; (d) if( !x ) i+ ;14已知int i=0,x=0; 下面while语句执行时循环次数为( )。while( !x & i 3 ) x+ ; i+

5、 ; (a) 4 (b) 3 (c) 2 (d) 115已知int i=3;下面do_while 语句执行时循环次数为( )。do i-; coutiendl;while( i!= 1 );(a) 1 (b) 2 (c) 3 (d) 无限16下面for语句执行时循环次数为( )。 for ( int i=0,j=5;i=j; ) cout i j endl;i+; j-;(a) 0 (b) 5 (c) 10 (d) 无限17执行以下程序段后,屏幕的显示结果是( )。 i=10; s=0; do s=s+i; i+; while(i=10); couts;(a)10 (b)11 (c)12 (d

6、)2118. 已知 int x=1, y=0, w ; 执行下面程序段后,w的值为( )。 if(x) if(y) w=x&y; else w=y;(a)0 (b)-1 (c)1 (d)不确定19执行语句 x=1; while( +x7 )cout*; 后输出结果是:( )(a) * (b) * (c) * (d) *20执行以下程序段后,屏幕的显示结果是( )。 int i=0; do i+; while(i=0); coutiendl;(a) 0 (b) 1 (c) 2 (d) 321以下正确的函数原型为( )。(a) f1( int x; int y ); (b) void f1( x,

7、 y );(c) void f1( int x, y ); (d) void f1( int, int );22有函数原型 void fun2( int ); 下面选项中,不正确的调用是( )。(a) int x = 21; fun2( x ); (b) int a = 15; fun2( a*3 ); (c) int b = 100; fun2( &b ); (d) fun2( 256 );23有函数原型 void fun3( int * ); 下面选项中,正确的调用是( )。(a) double x = 2.17; fun3( &x ); (b) int a = 15 ; fun3( a*

8、3.14 ); (c) int b = 100; fun3( &b ); (d) fun3( 256 );24有函数原型 void fun4( int & ); 下面选项中,正确的调用是( )。(a) int x = 2.17; fun4( &x ); (b) int a = 15; fun4( a*3.14 );(c) int b = 100; fun4( b ); (d) fun4( 256 ) ;25有声明 int fun5( int ); int (*pf)(int) = fun5; 下面选项中,正确的调用是( )。(a) int a=15; int n=fun5(&a); (b) i

9、nt a = 15; cout(&pf)(a);(c) cout(*pf)( 256 ); (d) cout n; int an; 27下列数组定义语句中,不合法的是( )。(a) int a3 = 0, 1, 2, 3 ; (b) int a = 0, 1, 2 ;(c) int a3 = 0, 1, 2 ; (d) int a3 = 0 ;28已知 int a10 = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , *p = a ;则不能表示数组 a 中元素的式子是( )。(a) *a (b) *p (c) a (d) a p-a 29以下不能对二维数组a进行正确初始化的语句

10、是( )。(a) int a23 = 0 ;(b) int a3 = 0,1 , 0 ;(c) int a23 = 0, 1 , 2, 3 , 4, 5 ;(d) int a3 = 0, 1, 2, 3, 4, 5 ;30已知int a3 = 0, 1 , 2, 3, 4 , 5, 6 , 7 ; 则 a21的值是( )。(a) 0 (b) 2 (c) 6 (d) 731已知int a33 = 1, 2, 3, 4, 5, 6, 7, 8, 9 ; 则不能表示数组元素a21的地址是( )。(a) &a21 (b) *(a2+1) (c) a2+1 (d) *(a+2)+132已知char *a

11、= fortran, basic, pascal, java, c+ ; 则 couta3;的显示结果是( )。(a) t (b) 一个地址值 (c) java (d) javac+33若用数组名作为调用函数的实参,则传递给形参的是( )。(a) 数组存贮首地址 (b) 数组的第一个元素值(c) 数组中全部元素的值 (d) 数组元素的个数34设有变量定义 int a=3,5,7,9,11, *p=a+2, y ; 执行语句 y=*p ; 后,变量y的值是:( )(a) 6 (b) 7 (c) 8 (d) 935设有变量定义 int a34; 能够表示元素a21的值有:( ) (a) *a2+1

12、 (b) &a21 (c) *a21 (d) *(a2+1)36设有说明语句char *s=”ABCD”; 下列选项中,输出字符 ”CD” 的代码是:( ) (a) cout*s+2; (b) couts2; (c) couts+2; (d) coutx (c) point-x (d) (*point).y39已知int a3=0,1,2,3, 4 , 5, 6 , 7 ; 则 a22的值是( )。(a) 1 (b) 3 (c) 6 (d) 040有int ary5=1,2,3,4,5; 以下表达式值等于3的是( )。(a)aryary1 (b)ary3 (c)*(ary+3) (d) *ar

13、y+341.有关类和对象的说法不正确的是( )(a) 对象是类的一个实例(b) 一个类只能有一个对象(c) 任何一个对象只能属于一个具体的类(d) 类与对象的关系和数据类型与变量的关系相似42若有以下说明,在类外使用对象objX成员的正确语句是( )。 class X int a; void fun1(); public: void fun2();X objX ;(a) objX.a=0; (b) objX.fun1(); (c) objX.fun2(); (d) X:fun1();43在类定义的外部,可以被访问的成员有( )。(a) 所有类成员 (b) private或protected的类

14、成员(c) public的类成员 (d) public或private的类成员 44说明一个类的对象时,系统自动调用( );撤消对象时,系统自动调用( )。(a) 成员函数 (b) 构造函数 (c) 析构函数 (d) 友员函数45下面对构造函数的不正确描述是( )。(a) 系统提供默认的构造函数 (b) 构造函数可以有参数,所以也可以有返回值(c) 构造函数可以重载 (d) 构造函数可以设置默认参数46下面对析构函数的正确描述是( )。(a) 系统不提供默认的析构函数 (b) 析构函数必须由用户定义(c) 析构函数没有参数,也没有返回值 (d) 析构函数可以设置默认参数47关于类的静态成员的不

15、正确描述是( )。(a) 静态成员不属于对象,是类的共享成员(b) 静态数据成员要在类外定义和初始化(c) 静态成员函数不拥有this指针,需要通过类参数访问对象成员(d) 只有静态成员函数可以操作静态数据成员 48当一个派生类公有继承一个基类时,基类中的所有公有成员成为派生类的( )。(a) public成员 (b)private成员 (c) protected成员 (d)友员49当一个派生类私有继承一个基类时,基类中的所有公有成员和保护成员成为派生类的( )。(a) public成员 (b)private成员 (c) protected成员 (d)友员50当一个派生类保护继承一个基类时,基

16、类中的所有公有成员和保护成员成为派生类的( )。(a) public成员 (b)private成员 (c) protected成员 (d)友员51不论派生类以何种方式继承基类,都不能直接使用基类的( )。(a) public 成员 (b)private成员(c) protected成员 (d)public 成员和protected成员52在c+中,可以被派生类继承的函数是( )。(a) 成员函数 (b)构造函数 (c) 析构函数 (d)友员函数 53在C+中,要实现动态联编,必须使用( )调用虚函数。(a) 类名 (b) 派生类指针 (c) 对象名 (d) 基类指针54下列函数中,不能说明为虚

17、函数的是( )。(a) 私有成员函数 (b) 公有成员函数 (c) 构造函数 d) 析构函数55在派生类中,重载一个虚函数时,要求函数名、参数的个数、参数的类型、参数的顺序和函数的返回值( )。(a) 相同 (b) 不同 (c) 相容 (d) 部分相同56下面函数原型中,( )声明了fun为纯虚函数。(a) void fun()=0; (b)virtual void fun()=0;(c) virtual void fun(); (d)virtual void fun() ;57若一个类中含有纯虚函数,则该类称为( )。(a) 基类 (b)纯基类 (c) 抽象类 (d) 派生类 58下列流类中

18、可以用于处理文件的是( )。(a) ios (b) iostream (c) strstream (d) fstream 59在下列选项中( )是istream类的对象。(a) cerr (b) cin (c) clog (d) cout60要求打开文件 D:file.dat,并能够写入数据,正确的语句是( )。(a) ifstream infile( “D:file.dat”, ios:in ) ;(b) ifstream infile( “D:file.dat”, ios:out ) ; (c) ofstream outfile( “D:file.dat”, ios:in ) ;(d) f

19、stream infile( “D:file.dat”, ios:in | ios:out ) ;二写出下列程序的执行结果 1#include using namespace std; int main() int i=1; switch(i) case 1:i+; case 2:i+; case 3:i+; break; default:i+; couti=iendl; 2. #includeusing namespace std;int main() int i = 1; while( i=10 ) if( +i % 3 != 1 ) continue; else cout i endl;

20、 3#include using namespace std; int main() int i=1; while (i=10) if(i%2) couti ; i+; coutendl; 4#includeusing namespace std;int main() int a=0; for(int i=1;i=3;i+) switch(i) case 1: a=i; break; case 2: a+=i; break; case 3: a*=i; couta=aendl; 5. #includeusing namespace std;int main()int i,j,k; for( i

21、=1; i=5; i+ ) for( k=1; k=5-i; k+ ) cout ; for( j=1; j=2*i-1; j+ ) cout*; coutendl; 6. #includeusing namespace std;#includeint f(int) ;int main() int i; for(i=0;i3;i+) coutf(i)endl;int f(int a) int b=0 , c=1; b+; c+; return int(a+pow(double(b),2)+c); 7#includeusing namespace std;int f(int);int main(

22、) int a=1, i; for(i=0; i3; i+) coutf(a)endl;int f(int x) int y=1; static int z=3; y=y+10; z=z+20; return (x*y+z); 8.#includeusing namespace std;int main()void f(int m ) coutm1) f(m-1); int main() f(4); coutendl; 9. #include using namespace std;int main() int i, count=0, sum=0; double average; int a=

23、 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ; for( i=0; i10; i+ ) if( ai % 2=0 ) continue; sum+=ai; count+; average=sum/count ; coutcount= count taverage= averageendl; 10#includeusing namespace std;int main() int a= 4,3,1,-7,10,12,-2,6,9,25; int i, m ; m=a0; for(i=1;i10;i+) if(aim) m=ai; coutdata is mendl; 11. #

24、include using namespace std;int f(int b , int m,int n) int i,s=0; for(i=m; in; i=i+2) s=s+bi; return s; int main() int x, a=1,2,3,4,5,6,7,8,9; x=f(a,3,6); coutxendl; x=f(a,6,9); coutxendl; 12#includeusing namespace std;class A public: int f1(); int f2(); void setx( int m ) x=m; coutxendl; void sety(

25、 int n ) y=n; coutyendl; int getx() return x; int gety() return y; private: int x, y ;int A:f1() return x+y; int A:f2() return x-y; int main() A a ; a.setx(10) ; a.sety(5) ; couta.getx() ta.gety()endl ; couta.f1() ta.f2()endl ; 13. #include using namespace std; class B1 public: B1(int i) cout调用基类B1的

26、构造函数:iendl; ; class B2 public: B2(int j) cout调用基类B2的构造函数:jendl; ; class D: public B1, public B2 public: D(int a,int b,int c):B2(b),B1(c),b1(a) cout调用派生类D的构造函数:a+b*cendl; private: B1 b1; int main() D obj( 3, 2, 1 ); 三程序填空题 1.给定函数下列程序从键盘上输入x的值,求y的值,在横线上填上适当的内容。#includeusing namespace std;int main() int x , y, k ; cinx ; k = _ _(1) _ ; sw

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1