第一范文网 - 专业文章范例文档资料分享平台

C 自考历年真题小集

来源:用户分享 时间:2025/6/1 13:51:06 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

void Print(______) {

______; }

void main() {

ClassA a; ClassB b; Print(a); Print(b); }

50.下列程序的运行结果如下: x=22,y=22

根据结果将程序补充完整。 #include

template <______> void f(______) {

if(sizeof(T1)>sizeof(T2)) x=(T1)y; else

y=(T2)x; }

void main(){ double x=134.2; int y=22; f(x,y);

cout<<″x=″<}

五、程序分析题(本大题共2小题,每小题5分,共10分) 请给出下面程序的输出结果 51. #include < iostream. h > class Class {

public:

static int var; Class() {

var+ +; } };

int Class::var = 0; void main() {

cout < < ″Class::var =″ < < Class: : var < < endl; Class cl ;

cout < <″cl. var=″ < Class c2, c3 ;

cout < < ″c2. var =″ < < c2. var < < endl; }

52. #include < iostream. h > class A {

public: A();

void Show() ; ~A(); private:

static int c; }; int A::c =0; A::A() {

cout < < ″constructor.″ < < endl; c+ =10; }

void A: :Show() {

cout< < ″c=″ < } A::~A() {

cout < < ″destructor. ″ < < endl; }

void main() {

A a,b; a. Show(); b. Show(); }

六、程序设计题(本大题共l小题,共10分)

53.利用LOCATION类,使用继承定义圆类CIRCLE,圆由圆心和半径构成。提供得到圆心坐标和半径的成员函数、以及计算圆的周长和面积的成员函数。在主程序中创建两个圆A和B,圆心坐标分别为(0,3)、(3,7),按如下格式输出两个圆的圆心坐标、周长和面积,并计算和输出两个圆的圆心之间的距离。考试大收集整理 A:(xl,y1,r1),Girth=g1,Area=a1 B:(x2,y2,r2),Girth=g2,Area=a2 A(xl,y1),B(x2,y2),Distance=d

定义LOCATION类,该类没有“继承”等现象。注意二维坐标点之间的距离公式。

class LOCATION{ double x,y;

public: virtual double getx()const{return x;}; virtual double gety()const{return y;}; virtual double dist(LOCATION &s)const;

LOCATION(double x,double y):x(x),y(y){};}; double LOCATION::dist(LOCATION &s)const{ double xd=s.x — x,yd=s.y — y; return sqrt(xd*xd+yd*yd);}

搜索更多关于: C 自考历年真题小集 的文档
C 自考历年真题小集.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3zkkv7lj649o8y29xxc8_10.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top