2010-2011学年第二学期《C 》信安10试卷A===答案及评分标准(2)

2021-04-05 13:00

大学c++试题带答案

四、读程序填空(每空2分,共10分)

1. ①k++ ②n%k==0

2. ③f=fac(n-1)*n

3. ④x=f ⑤num=t.num

五、编程题(第1题8分,第2题12分,共20分) 1.

#include<iostream>

using namespace std;

void main()

{

int i;

int s;

s=0; (2分)

for(i=0;i<50;i++)

{

s = s + 2*i+1; (4分)

}

cout<<"s="<<s<<endl; (2分)

}

2.参考程序

#include<iostream>

using namespace std;

class vehicle

{

public:

vehicle(int tmpWheels,int tmpWeight)

{

wheels = tmpWheels;

weight = tmpWeight;

}

virtual void print()

{

cout<<"vehicle:"<<endl;

cout<<"wheels:"<<wheels<<endl;

cout<<"weight:"<<weight<<endl;

}

private:

int wheels;

int weight;

};

2

6分) (


2010-2011学年第二学期《C 》信安10试卷A===答案及评分标准(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:计算机室管理制度

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: