注意:此页面搜索的是所有试题
题目内容
(许昌学院面向对象程序设计)
[应用题,25分] #include
fun(int *s,int n1,int n2)
{ int t;
while(n1<>
{t=*(s+n1);
*(s+n1)=*(s+n2);
*(s+n2)=t;
n1++;n2--; }
}
main()
{ int a[10]={1,2,3,4,5,6,7,8,9,0},i,*p=a;
fun(p,0,3);fun(p+3,1,6);
for(i=0;i<10;i++)
{ if(i%5= =0)cout<<>
cout<
}
运行结果:
fun(int *s,int n1,int n2)
{ int t;
while(n1<>
{t=*(s+n1);
*(s+n1)=*(s+n2);
*(s+n2)=t;
n1++;n2--; }
}
main()
{ int a[10]={1,2,3,4,5,6,7,8,9,0},i,*p=a;
fun(p,0,3);fun(p+3,1,6);
for(i=0;i<10;i++)
{ if(i%5= =0)cout<<>
cout<
}
运行结果:
参考答案