云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C 自考历年真题小集

C 自考历年真题小集

  • 62 次阅读
  • 3 次下载
  • 2025/6/8 5:43:30

void setValue(int x,int y) { xx = x;yy = y;} int max( ){

return xx > yy? xx:yy; } };

void main( ){ CMax m( );

m.setValue(20,30); cout <<″Max=″<} 45.#include

using namespace std; class A{ public:

char name[255]; private:

char * getName( ) { return name; } };

class B:public A{ public: B(char * n){

strcpy ( name,n); } };

void main( ){

B b(″Hello!″); cout <<″Name:″<}

四、完成程序题(本大题共5小题,每小题4分,共20分) 46.将下面程序补充完整,使程序输出结果为: Begin Welcome Show End

程序如下: #include

using namespace std; class A{ public: __________{

cout <<″Begin″<} void show( ){ cout<<″Show″<}

___________{ cout<<″End″<} };

A object; int main( ){

cout <<″Welcome″

47.请将下面程序补充完整,使程序可以正常打印9×9乘法口诀。 #include

using namespace std; class A { private:

int a;int b; public: __________

{ a = x;b = y; } void set(int x,int y) { a = x;b = y; } void display( ){ cout<} };

int main( ){ A a(1,1);

for(int i=1;i<=9;i++){ for(int j=1;____;j++){ a.set(j,i); a.display( ); cout<<″″; }

cout<}

return 0; }

48.将下面程序补充完整,使程序可以输入学生信息并计算平均成绩。 #include #include

using namespace std; class Student{ private:

char name[255]; int score[10]; public:

Student(char n[ ],int s[ ]){ ___________;

for(int i=0;i<10;i++){ score[i]=s[i]; } }

void Show( ){ int sum=0;

for(int i=0;i<10;i++){ _______________; }

cout<<″名字:″< < name<<″,平均成绩:″<} };

void main( ){ char name[255]; int score[10];

cout<<″姓名:″;cin>>name; for(int i=0;i<10;i++){

cout<<″成绩″>score[i]; }

Student s(name,score); s.Show( ); }

49.将下面程序补充完整,使程序可以正常运行,并释放内存。 #include _______ class A { private: T * data; int length; public: A (int len){ length=len;

data=new T[len]; }

~A( ){ _________ }

T& operator[](int i){ return data[i]; } };

int main( ){ A obj(2); obj[0]=1; obj[1]=2;

cout

50.将下面程序补充完整,使程序运行结果为: C1ass A Class B 程序如下: #include #include class A{ public:

virtual void GetA( ) = 0; };

class B:public A{ private:

char str[32]; public: void GetA( ){

cout<<″Class A″<}

const char * GetB( ) {_____ }

B(char * s){

strcpy(str,s); } };

void main( ){ A * a;

B b(″Class B″); a=_________; a-> GetA( ); cout

五、程序分析题(本大题共2小题,每小题5分,共10分) 51. #include

using namespace std; int main( ){ int i,j;

for(i=l;i<=4;i+=1) for(j=2;j<=4;j+=j){ if(i+j<5)

cout<<″ + ″; else

cout<<″ * ″; }

return 0;

搜索更多关于: C 自考历年真题小集 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

void setValue(int x,int y) { xx = x;yy = y;} int max( ){ return xx > yy? xx:yy; } }; void main( ){ CMax m( ); m.setValue(20,30); cout <<″Max=″<} 45.#include using namespace std; class A{ public: char name[255]; private: char * getName( ) { return name; } }; class B:public A{ public: B(char * n){ strcpy ( name,n); } }; v

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com