华科 c++期末考试试卷答案

上传人:第*** 文档编号:33911626 上传时间:2018-02-19 格式:DOC 页数:9 大小:72KB
返回 下载 相关 举报
华科 c++期末考试试卷答案_第1页
第1页 / 共9页
华科 c++期末考试试卷答案_第2页
第2页 / 共9页
华科 c++期末考试试卷答案_第3页
第3页 / 共9页
华科 c++期末考试试卷答案_第4页
第4页 / 共9页
华科 c++期末考试试卷答案_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《华科 c++期末考试试卷答案》由会员分享,可在线阅读,更多相关《华科 c++期末考试试卷答案(9页珍藏版)》请在金锄头文库上搜索。

1、2008-2009 学年度第二学期华 中 科 技 大 学 C+语 言 程 序 设 计 试 卷 ( A)(考试时间:150 分钟 考试方式:闭卷)所有答案必须写在答题纸上一、单项选择题 (30 小题,每小题 1 分,共 30 分) 1、C+程序中的语句必须以( B )结束A 冒号 B 分号 C 空格 D 花括号2、下列选项中,( A )不是分隔符A 标识符 B; C : D ( )3、执行语句int a = 10, b ;int 后,下列正确的语句是( B)A 4、设 I=1,J=2,则表达式 I+ +J 的值为(C ) 5、执行下列语句后,int x , y ;x = y = 1 ; +x |

2、 +y ;y 的值是( C)不确定 6、逗号表达式(x = 4 * 5 , x * 5 ), x + 25的值为(D )A 25 B 20 C 100 D 457、已知 int i, x, y;在下列选项中错误的是(C)A if ( x C if ( xy ) i ; D if ( x + y ) i+;8、i=2,执行下列语句后的值为(B )switch ( i ) case 1: i+;case 2: i;case 3: +i; break;case 4: i;default : i+;A 1 B 2 C 3 D 49、已知 int i = 3;下面 do _ while 语句执行时循环次

3、数为(B)do i- ; cout =0 ) ;C int a=5; while ( a ) a ; ;D int i=3 ; for ( ; i ;i) ;11、以下正确的函数原型为( D )A f (int x ; int y); B void (x , y);C void (int x , y); D void f (int , int);12、有函数原型 void fun2 (int * ), 下面选项中,正确的调用是( C )A double x = 2.17; fun2 (C int b = 100; fun2 (13、有声明int fun4 (int); int (* pf) (

4、int) = fun4;下面选项正确的是( B )A int a = 15; int n = fun4 (C coutn; int an;17、已知 int a10=0,1,2,3,4,5,6,7,8,9和*p=a,则不能表示数组 a 中元素的式子是( C )A *a B *p C a D a p-a18、以下不能对二维数组 a 进行正确初始化的语句是( C )A int a23 = 0;B int a3 = 0,1,0;C int a23 = 0,1,2,3,4,5D int a3 = 0,1,2,3,4,5,6,719、已知 int a33 = 1,2,3,4,5,6,7,8,9,则不能表

5、示数组元素 a21的地址是( B )A &a21 B * (a2 + 1)C a2 + 1 D * (a + 2) + 120、若用数组名作为调用函数的实参,则传递给形参的是( A )A 数组存储首地址 C 数组的第一个元素值B 数组中全部元素的值 D 数组元素的个数21、下列描述中,错误的是( A )A 输出字符指针就是输出字符串B 输出字符指指针的间接引用就是输出单个字符C 具有相同字符的两个字符串常量相等D 两个数组名的比较是地址的比较22、判断字符串 s1 是否大于字符串 s2 的表达式为( D )A s1 s2 B strcmp ( s1, s2) = = 0C strcpy (s1

6、,s2) 0 D strcmp (s2,s1) 023、在下列结构变量的定义中,不正确的是( D )A struct employee B struct char name20; char name 20;long code; long code;emp; emp;C struct employee D struct char name20; char name20;long code; long code ; employee;employee emp ; employee emp;24、假定有以下声明和定义,则下面引用形式错误的的( B )struct student int num;fl

7、oat score;stu3=1001,80,1002,75,1003,91,*p=stu;A p-num B (p+).num C (p+)-num D (*p).num25、若有以下声明和定义,则下列错误的引用是( D )struct workerint no;char name20;w,*p=A w.no B p-no C (*p).no D *p.no26、关于类和对象不正确的说法是( C )A 类是一种类型,它封装了数据和操作B 对象是为类的实例C 一个类的对象只有一个D 一个对象必属于某个类27、下面对构造函数的不正确描述是( B )A 系统可以提供默认的构造函数。B 构造函数可以

8、有参数,所以也可以有返回值C 构造函数可以重载。D 构造函数可以设置默认参数。28、在类定义的外部,可以被访问的成员有( C )A 所有类成员 B private 或 protected 的类成员C public 的类成员 D public 或 private 的类成员29、在下列选项中, (C )是错误的。A gets 和函数 puts 可以输入输出包含空格的字符串B cin 不能输入包含空格的字符串 C cout 不能输出包含空格的字符串D 使用赋值运算符总可以对字符数组整体赋值30、下列选项中, ( C )具有文件作用域。A 语句标号 B 局部变量 C 全局变量 D 形式参数二、程序填空

9、(每空 2 分,共 10 分 ) 1、函数 yanghui 的功能是把杨辉三角形的数据赋给二维数组的下半三角,请填空。void yanghui(int x66) int i,j;x00=1;for(i=1;ivoid main() int i , s = 0 ;for ( i = 0 ; iint f1 ( int a, int b) return a + b; int f2 ( int a, int b) return a - b; int f3 ( int ( *t) ( int , int ) , int a , int b) return (*t) (a , b); void main

10、() int (*p) (int ,int );p = f1;cout void main()int a 3=0,1,2,3,4,5,6,7,8;cout#includeclass point public:point(float x,float y) a=x;b=y;coutclass T public:T( int x) a=x; b+=x;static void display( T c)coutusing namespace std;void main()int score;coutscore;if(score=85)cout=60)coutusing namespace std;vo

11、id display(double x)cout#include#include#includeusing namespace std;void main()int n;coutn;int *p=new intn;srand(unsigned(time(0);for(int *a=p;a#include#include#includeusing namespace std;class Studentfloat score;static float total;static int count;public:void scoretalcount(float s)score=s;total+=s;+count;static float sum()return total;static float average()return total/count;int Student:count=0;float Student:total=0;void main()Student s1,s2,s3;s1.scoretalcount(80);s2.scoretalcount(70);s3.scoretalcount(60);cout总成绩为:Student:sum();coutendl;cout平均分为:Student:average();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 解决方案

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号