分析程序写出结果Word格式.docx
《分析程序写出结果Word格式.docx》由会员分享,可在线阅读,更多相关《分析程序写出结果Word格式.docx(14页珍藏版)》请在冰豆网上搜索。
p1++,p2++)
*p2=*p1;
*p2=’\0’;
p1=str1;
”str1is:
”<
p1<
”str2is:
p2<
_______str1=”Ilovechina!
”_________________________
_________str2=”Ilovechina!
”_______________________
#include<
usingnamespacestd;
intmain()
{charc1=’a’,c2=’d’,c3=’f’;
c1+=2;
c2+=2;
c3+=2;
c1<
c2<
c3<
return0;
运行结果:
cfh
2.写出下列程序的输出结果。
inti,j,m,n;
{i=5;
j=6;
m=++i+j++;
n=(++i)+(++j)+m;
i<
’\t’<
j<
m<
n<
781227
3.写出下列程序的输出结果。
{constintn=5;
inta[n]={9,6,3,4,5},i,t;
for(i=0;
n/2;
i++)
{t=a[i];
a[i]=a[n-i-1];
a[n-i-1]=t;
n;
cout<
a[i]<
”“;
54369
1.structabc
{inta,b,c;
};
main()
{structabcs[2]={{1,2,3},{4,5,6}};
intt;
s[0].c<
’\t’;
t=s[0].a+s[1].b;
t;
___________3_____________________
____________6____________________
2.
voidswap(int*p1,int*p2)
{int*p;
p=p1;
p1=p2;
p2=p;
}
main()
{inta=3,b=5;
int*pt1,*pt2;
pt1=&
a;
pt2=&
b;
*pt1<
’,’<
*pt2<
swap(pt1,pt2);
___________3.5_____________________
______________3.5__________________
1、
iostream.h>
intt()
{
staticinti=100;
i+=5;
returni;
voidmain()
”i=”<
t()<
’\n’;
i=105i=100
2、
voidswap1(int*p1,int*p2)
intt;
t=*p1;
*p1=*p2;
*p2=t;
voidswap2(int&
p1,int&
p2)
int*t;
t=p1;
p2=t;
voidmain(void)
intx,y;
inta,b;
x=10,y=20;
swap1(&
x,&
y);
;
a=100,b=200;
swap2(a,b);
"
x="
x<
y="
y<
'
\n'
a="
a<
b="
b<
运行结果是:
x=20,y=10
a=100,b=200
1、#include<
i=105
i=110
inti,x,num;
cin>
>
x;
while(x){
num=x%10;
num;
x=x/10;
}
若输入x为145734
则输出为:
437541
3#include<
structs{
intm;
floatx;
};
voidswap(ss1,ss2)
{st;
t=s1;
s1=s2;
s2=t;
sfun(ss1,ss2)
st;
t.m=s1.m+s2.m;
t.x=s1.x+s2.x;
returnt;
sr1={100,250.5},r2={200,350.5};
swap(r1,r2);
”r1.m=”<
r1.m<
”r1.x=”<
r1.x<
”r2.m=”<
r2.m<
”r2.x=”<
r2.x<
ssum;
sum=fun(r1,r2);
”sum.m=”<
sum.m<
”sum.x=”<
sum.x<
执行程序后输出:
r1.m=100r1.x=250.5
r2.m=200r2.x=350.5
sum.m=300sum.x=601
4、#include“iostream.h”
staticchara[]=”Radio&
TVUniversity”;
staticintb[8]={6,8,9,2};
char*p=a;
int*q;
q=b;
a[1]<
*p<
*(a+6)<
p[2]<
*q=*(q+1)+2;
*(q+2)=*q*2;
q++;
cout<
b[5]<
*b<
b[1]<
’,’<
*q++;
a,R,T,d
0,10,8,8
1.#include<
intmain()
{
charc1=’A’,c2=’D’,c3=’k’;
c2+=3;
c3-=4;
“”<
”“<
_________C_____G______g__________________________
{
i=361;
j=i/100;
m=i%10;
n=(i%100)/10;
if(i==j*j*j+m*m*m+n*n*n)cout<
”是水仙花数”<
elsecout<
”不是水仙花数”<
_______361不是水仙花数___________________________
3#include<
constintn=9;
inta[n]={9,6,3,4,5,45,32,78,21},i,t;
输出结果是:
2178324554369
4有如下程序:
#include<
classA{
public:
A()
{cout<
"
A"
classB{public:
B()
{cout<
B"
classC:
publicA{Bb;
C(){cout<
C"
intmain()
{Cobj;
执行后的输出结果是:
ABC
5.#include<
voidswap(int*p1,int*p2)
{int*p;
p=p1;
{inta=3,b=5;
int*pt1,*pt2;
3,5
3,5
6.#include<
iomanip>
intmain()
cout.fill('
*'
);
cout.width(6);
#'
123<
endl;
###123
3.#include<
intage(int);
{cout<
age(3)<
intage(intn)
{intc;
if(n=