好文档 - 专业文书写作范文服务资料分享网站

电大本科C语言程序设计期末复习题

天下 分享 时间: 加入收藏 我要投稿 点赞

电大本科C语言程序设计期末复习题

; // 将 aa 的值赋给 a

b=bb ; // 将 bb 的值赋给 b }

int fA () ; int

fB() ; };

int ABC::fA( ) { return a+b; } int ABC::fB( ) { return a*b; }

三、下列程序运行后的输出结果 1. # include void main() {

int s=0;

}

cout <<\<

i,s=15,56

2. # include int a=5; void main() {

int a=10,b=20; cout <

{ int a=0,b=0;

for (int i=1; i<6; i++) {

a+=i; b+=a; }

cout <

for (int i=1; ; \ i++) {

}

i

cout <50) break;

\

i

} f (i%2==0) s+=i;

11 / 25

电大本科C语言程序设计期末复习题

10 20 15 35 5 10 20

3. # include cout <

good!pass!nad!well!

4. # include void SB(char ch) { void main() switch(ch){

{

case \ char a[]=\ 20

int case \ i1=0,i2=0,i=0;

cout while (a[i]) {<<\

case \ f (a[i]==\

cout <<\ f (a[i]==\

default:

cout ++;

<<\ }

} cout <

void main() {}

char

4 3

a1=\

5. # include SB(a1);SB(a2);SB(a3);void main()

SB(\

12 / 25

i i i 电大本科C语言程序设计期末复习题

{

int

a[9]={2,4,6,8,10,12,14,16,18};

for (int i=0; i<9; i++) {

cout <

if ((i+1)%3==0) cout <

6. # include void LE(int * a,int * b) { int x=*a; *a=*b; *b=x; cout <<*a<<\\ }

void main() {

int x=10,y=25;

LE(&x,&y); cout <

7. # include # include void main() {

char

*a[5]={\adre\ char *p1,*p2; p1=p2=a[0]; for (int i=0; i<5; i++) {

if (strcmp(a[i],p1)>0) p1=a[i];

if (strcmp(a[i],p2)<0) p2=a[i];

}

cout <

13 / 25

电大本科C语言程序设计期末复习题

worker cadre

8. # include int LB(int *a,int n) { int s=1;

for (int i=0; i

s*=*a++;

return s; }

void main() {

int

a[]={1,2,3,4,5,6,7,8}; int

b=LB(a,5)+LB(&a[3],3); cout <<\ }

A(int aa,int bb) {

a=aa; b=bb;

cout <

void main() {

A x,y(2,3),z(4,5); } 2 3 4 5

10. # include template class FF {

B=240

9. # include class A {

int a,b; public :

A() { a=b=0; }

TT a1,a2,a3; public :

FF(TT b1,TT b2,TT b3) {

a1=b1; a2=b2; a3=b3;

14 / 25

电大本科C语言程序设计期末复习题

}

TT Sum() { return a1+a2+a3; } };

void main() {

FF x(2,3,4),y(5,7,9); cout <

\ } 9 21

11. # include # include struct Worker{

char name[15]; // 姓名

int

age; // 年龄 float

pay; // 工资 };

void main() {

Worker x;

char *t=\

int d=38; float f=493;

strcpy(x.name,t);

x.age=d; x.pay=f;

cout

<

liouting 38 493

12. # include class A {

int a; public:

A(int aa=0) { a=aa; }

~A() { cout <<\A!\ } };

class B:public A { int b; public:

15 / 25

电大本科C语言程序设计期末复习题

电大本科C语言程序设计期末复习题;//将aa的值赋给ab=bb;//将bb的值赋给b}intfA();intfB();};int
推荐度:
点击下载文档文档为doc格式
4botr9l6uj10e609m87w9sc9l3ppnv019ut
领取福利

微信扫码领取福利

微信扫码分享