C程序设计综合练习题读程序写结果题Word格式.docx

上传人:b****1 文档编号:13251530 上传时间:2022-10-08 格式:DOCX 页数:24 大小:14.84KB
下载 相关 举报
C程序设计综合练习题读程序写结果题Word格式.docx_第1页
第1页 / 共24页
C程序设计综合练习题读程序写结果题Word格式.docx_第2页
第2页 / 共24页
C程序设计综合练习题读程序写结果题Word格式.docx_第3页
第3页 / 共24页
C程序设计综合练习题读程序写结果题Word格式.docx_第4页
第4页 / 共24页
C程序设计综合练习题读程序写结果题Word格式.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

C程序设计综合练习题读程序写结果题Word格式.docx

《C程序设计综合练习题读程序写结果题Word格式.docx》由会员分享,可在线阅读,更多相关《C程序设计综合练习题读程序写结果题Word格式.docx(24页珍藏版)》请在冰豆网上搜索。

C程序设计综合练习题读程序写结果题Word格式.docx

2.

#include<

iostream.h>

voidswapl(inta,intb)

inttemp=a;

a=b;

b=temp;

voidswap2(int*a,int*b)

{

inttemp=*a;

*a=*b,*b=temp;

voidswap3(int*a,int*b)

int*temp=a;

a=b,b=temp;

voidswap4(int&

a,int&

b)

inta=10,b=20;

swapl(a,b);

a<

"

:

b<

swap2(&

a,&

b);

swap3(&

swap4(a,b);

3.&

&

iostream.h>

voidprint(intw)

inti;

if(w!

=0)

{

print(w-1);

for(i=1;

i<

=w;

i++)

cout<

w;

}

print(4);

4.

#definesw(x,y){x^=y;

y^=x;

x^=y;

inta=10,b=01;

sw(a,b);

b;

5.假定输入10个整数:

32,64,53,87,54,32,98,56,98,83。

下列程序的输出结果是什么?

voidmain()

inta,b,c,x;

a=b=c=0;

for(intk=0;

k<

10;

k++)

cin>

>

x;

switch(x%3)

{

case0:

a+=x;

break;

case1:

b+=x;

case2:

c+=x;

}

c<

6.***

{intj,k;

for(j=5;

j>

0;

j--)

{for(k=j;

k>

k--)

cout<

*"

;

7.

intnNumber;

int*pPointer;

nNumber=15;

pPointer=&

nNumber;

nNumberisequalto:

nNumber<

*pPointer=25;

nNumber<

8.

int*pPointer;

voidSomeFunction()

pPointer=newint;

*pPointer=25;

SomeFunction();

Valueof*pPointer:

*pPointer<

deletepPointer;

9.

voidAddFive(int*Number)

*Number=*Number+5;

intnMyNumber=18;

Myoriginalnumberis"

nMyNumber<

AddFive(&

nMyNumber);

Mynewnumberis"

10.

intArray[3];

Array[0]=10;

Array[1]=20;

Array[2]=30;

int*pArray;

pArray=&

Array[0];

pArraypointstothevalue."

*pArray<

*(pArray+1)<

11.***

inti=4;

i="

i=5;

inti;

i=7;

i;

12.***

voidfun();

fun();

voidfun()

staticinta=1;

inti=5;

a++;

i++;

a="

13.&

classPoint

{public:

Point(intxx=0,intyy=0){X=xx;

Y=yy;

countP++;

}

Point(Point&

p);

intGetX(){returnX;

intGetY(){returnY;

voidGetC(){cout<

Objectid="

countP<

private:

intX,Y;

staticintcountP;

};

Point:

Point(Point&

p)

{X=p.X;

Y=p.Y;

intPoint:

countP=0;

voidmain()

{PointA(4,5);

PointA,"

A.GetX()<

A.GetY();

A.GetC();

PointB(A);

PointB,"

B.GetX()<

B.GetY();

B.GetC();

14.***

intaddDefault(intx=1,inty=2);

voidfun(void);

voidmain(void)

intaddDefault(intx=3,inty=4);

addDefault()<

fun();

intaddDefault(intx,inty)

x<

+"

y<

="

returnx+y;

voidfun(void)

15.***

#include<

voidmain()

{intm,n,a=3,b=3,number;

number=237;

m=number/5;

n=number%5;

m="

m<

n="

n<

a+=m;

b*=n;

a="

b="

16.***

{intwidth,height,result1,result2,result3;

height=3;

width=5;

result1=height>

3&

width>

=5;

result2=height>

3||width>

result3=!

(width>

=5);

result1"

result1<

result2"

result2<

result3"

result3<

17.***

{inti=32,j=6;

doubledf;

df=i/j+2.3;

df="

df<

i=df/3;

18.&

#include<

intc[10];

voidadd(intx,inty)

{staticinti=0;

c[i]=x+y;

i++;

{inta[10]={1,2,3,4,5,6,7,8,9,10};

intb[10]={10,9,8,7,6,5,4,3,2,1};

inti=0,k=0;

for(i=0;

add(a[i],b[i]);

c[i]<

19.

{chars[30]="

computer,mouse,key"

s<

while(s[i]!

='

\0'

{if(s[i]=='

m'

)//通过数组名和下标引用数组元素

k++;

i++;

k="

k<

20.

{chars[]="

C++program"

char*ps1="

computer"

char*ps2,*ps3=s;

ps2="

mouse"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1