logo资料库

2018华师计算机专硕918完整版.pdf

第1页 / 共4页
第2页 / 共4页
第3页 / 共4页
第4页 / 共4页
资料共4页,全文预览结束
2019 年 C++程序设计(918) Q 群:418095890 感谢优秀的群友 cqw (9569166**)整理分享!!! 2019 年 C++程序设计(918) 基本完整版 一、单项选择(10 题*2 分) 1.C++程序运行时,总是起始于( )。 A.程序中的第一条语句 C.main( ) 2.下列操作符不能作用于浮点数的是( A.++ B.+= C./ D.% B.预处理命令后的第一条语句 D.预处理指令 )。 3.C++语言中规定函数的返回值的类型是由( )。 4.对于一个有 m 列的数组,a[i][j]前的元素有几个( )。 A.return 语句中的表达式类型所决定 B.调用该函数时的主调用函数类型所决定 C.调用该函数时系统临时决定 D.在定义该函数时所指定的数据类型所决定 A.i*m+j B.j*m+i C.i*m+j-1 D.i*m+j+1 5.有语句 int i=3,j=4,*p=&i,请问下列哪个语句的功能等同于 i=j( )。 A.i=&j B.i=*p C.i=*&j D.i=**p 6.一个类的析构函数只有( )个。 A.0 B.1 C.2 D.3 7.class Foo{ int data;},请问 data 是( )。 A.公有数据成员 B.公有函数成员 C.私有数据成员 D.私有函数成员 8.对于 protected 继承,派生类从父类继承得到的( )访问权限在派生类是 protected A.public 成员 C.private 成员和 protected 成员 B.public 成员和 protected 成员 D.private 成员 9.类模板的使用实际上是将类模板实例化成一个具体的( )。 B.对象 C.函数 D.抽象类 A.类 还有一题实在想不起来。。不过难度和上面的题都是差不多的 二、程序结果输出(5 题*4 分) 1. #include using namespace std; int main(){ int a=1,b=1; for(;a<=100;a++){ if(b>=10) break; if(b%3==1){ b+=3; continue; 1
2019 年 C++程序设计(918) Q 群:418095890 } } cout< using namespace std; int main(){ } int arr[3][3]={1,2,3,4,5,6,7,8,9}; for(int k=0;k<3;k++){ } cout< #include using namespace std; int main(){ } char str[20]; cin>>str; int k=strlen(str); for(int i=0;i using namespace std; class A{ public: }; int A::n=1; int main(){ return n; A *a=new A(); delete a; cout<<"n="<getN(); 2
2019 年 C++程序设计(918) Q 群:418095890 } 5. cout<<"BASE "; cout<<"DERIVED "; ~Base(){ } #include using namespace std; class Base{ public: }; class Derived:public Base{ public: }; int main(){ } ~Derived(){ } Derived d; return 0; 三、代码填空题(10 个空*3 分) 1. 有 8 个评委打分,去掉一个最高分,去掉一个最低分,求平均分 #include using namespace std; int main(){ float score[8]; float aver=0,max=(1)_____,min=(2)_____; for(int i=0;i<8;i++){ cin>>score[i]; if(score[i]>max) (3)______ if((4)_______) aver+=score[i]; } aver=(5) ______; cout<<”最终平均分为:”< using namespace std; class A{ int *a; 3 2.
2019 年 C++程序设计(918) Q 群:418095890 public: A(int aa=0){ a=(6)______;//使用 aa 来初始化动态内存。 (7)______ } ~A(){ } }; 3. 有一个分数类 Fraction,通过重载<<输出分数形式,如”3/2” #include using namespace std; class Fraction{ int den,num; (8)_____ ostream& operator<<(ostream &os,const Fraction&fr); //此处省略 }; ostream& operator<<(ostream &os,const Fraction&fr){ } (9)___________ return(10) _______; 四、简答题(3 题*10 分) 1.请说明注释的作用?注释有几种?区别分别是什么? 2.请说明析构函数和构造函数的作用 3.请说明多态性和虚函数的作用 五、编程题(5 题*10 分) 1.用穷举法输入 1-100 的素数。 2.用递归的方法求 1+2+...+n。 3.请完成函数 int index(char *s,char *t) 函数的作用是返回字符串 t 出现在字符串 s 第一 次最左边的下标,若 t 不是 s 的子串则返回-1。 4.请编写抽象类 shape,然后派生出 Rectangle 和 Circle 类,要求完成计算面积。 5.每次从键盘读取一行文本,输出到文件”a.txt”中,当用户输入空行时结束。 4
分享到:
收藏