收藏 分销(赏)

长沙理工大学C++程序试卷16.doc

上传人:人****来 文档编号:4086073 上传时间:2024-07-29 格式:DOC 页数:6 大小:53.51KB
下载 相关 举报
长沙理工大学C++程序试卷16.doc_第1页
第1页 / 共6页
长沙理工大学C++程序试卷16.doc_第2页
第2页 / 共6页
长沙理工大学C++程序试卷16.doc_第3页
第3页 / 共6页
长沙理工大学C++程序试卷16.doc_第4页
第4页 / 共6页
长沙理工大学C++程序试卷16.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、C+程序设计试卷一, 填空题(每空1分,共15分)1. 被调函数在执行结束时,这个函数中定义的_类型的变量不被释放。2. 设struct studentint no;char name12;float score3; sl,* p = &sl;用指针法给sl的成员no赋值1234的语句是_。3. C语言程序中对文本文件的存取是以_为单位进行的。4. 设char string =This_is_a_book!;则数组的长度应是_。5. 设int a23 = 2,3;则数组元素_的值为3。6. 向对象程序的三大特征是:_、_与_。7. 设int a=5,则执行a+的结果是_,此时a的值是_。8.

2、派生类的3种继承方式分别是_、_和_。9. 绑定是指一个计算机程序自身彼此关联的过程。按照绑定所进行的阶段不同,可分为_和_。一、 单项选择题(每题2分,共20分)1. 设char str100;int i = 5;则引用数组元素的错误形式是 【 】A. stri + 10B. (str + i)C. (str + i - 1)D. (str + + ) + i)2. 设int x = 1,2,3,4,5,6,* p = x;则值为3的表达式是 【 】A. p + = 2, * + + pB. p + = 2, * p + +C. p + = 3, * pD. p + = 2, + + * p

3、3. 在函数内,定义变量时存储类型符可省略的是 【 】A. autoB. staticC. externD. register4. 设有定义语句structint a;float b; d3=1,4,2,5,6,7;则printf(3.1f n,d2. a * d2. b/d1. b);的输出是 【 】A. 2.5B. 2.0C. 8.0D. 8.45. 设有定义语句:enum t1 a1, a2 = 7, a3, a4 = 15time;则枚举常量a2和a3的值分别为 【 】A. 1和2B. 2和3C. 7和2D. 7和86. 为了避免嵌套的if-else语句的二义性,C+语言规定else总

4、是与【 】组成配对关系。A. 缩排位置相同的if B. 在它之前未配对的ifC. 在它之前未配对的最近的ifD. 同一行上的if7. sizeof(float)是一个 【 】表达式。A. 整型B. 双精度实型C. 浮点型D. 函数调用8.在C+中函数没有返回值时,函数的类型应定义为【 】A.void B.float C.int D. 无9.以下构造函数定义形式正确的是【 】A. int student(char*, int ); B. void student(char*,int ) C. void* student(char*,int)D. student(char*, *int) ;10.

5、关于delete运算符,下列描述中,【 】是错误的。A. 必须用于new返回的指针B. 适用于空指针C. 对一个指针可以使用多次delete运行符D. 在指针名前只用一对括号,而不管所删除数组的维数二、 读程序填空题(15分)1. 以下对数组a简单选择排序的程序,2. 请在_处补充相应的语句,使程序完整。#include void sort(int array,int n) int i,j,k,t; for(i=0;in-1;i+) k=i; for(j=i+1;jn;j+) if(arrayjarrayk) k=j; if(k!=i) t=arrayi; arrayi=arrayk; _;

6、main() int a10,i; for(i=0;iai; sort(_, _); for(i=0;i10;i+) coutai; coutendl;2. 以下是实现交换两个数的程序,请在_处补充相应的语句,使程序完整。#include void swap(_) int *t; t=*r; *r=*s; *s=t;main() int a=1,b=2,*p,*q; p=&a; q=&b; swap(_); cout*p*qendl;3. 以下程序的功能是输入一字符串(换行为结束标志)统计其中数字(0,1,9不单独统计)、空白和其它字符出现的次数。请在_处补充相应的语句,使程序完整。# inc

7、lude main() char c;int ;while(c = getchar()! = n)if(_) digit + + ;else if(c = =c = = t) + blank;else _;cout”digit =” digit”blank =”blank”other =”otherendl;四、阅读程序写输出结果(每题5分,共20分)1. 分析下面程序运行的结果。#include using namespace std;int main()int i,j,m,n;i=8;j=10;m=+i+j+;n=(+i)+(+j)+m;coutitj tmtnendl;return 0;

8、运行时输出:_。2. #include #include void main() char destination25; char blank = , c= C+, turbo = Turbo; strcpy(destination, turbo); strcat(destination, blank); strcat(destination, c); coutdestinationendl;运行时输出:_。3. #include main() void increment(void); increment(); increment(); increment();void increment(

9、void) static int x=0; x+; coutxendl;运行时输出为: 4. #include class basepublic:base()cout”destructing base”endl;class der:public basepublic:char *ch;public:void der(int i) ch = new chari; virtual der()delete ch;cout”destructing der” endl;void main()base *b= new der(20);delete b;运行时输出为:五、 编写程序(每题10分,共30分)1.编写一个程序,输入3个整数a,b,c,输出其中最大的数。2.编写一个程序,计算s= 15! 的值。3.实现一个用于计算体积的长方体类,要求该类:(1) 数据成员包括:长(length)、宽(width)与高(height)(2) 提供输入长、宽与高的成员函数;(3) 提供计算体积的成员函数; 第 6 页 共 6 页

展开阅读全文
相似文档                                   自信AI助手自信AI助手
猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 教育专区 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服