本人是菜鸟,高手帮忙调试一下啊!
#include<iostream.h>
void swap(int& i, int& j)
{
int tmp = i;
i = j;
j = tmp;
}
void Reverse(int A[],int from,int to)
{
for(int i=0;i<(to-from+1)/2;i++)
swap(A[from+i],A[to-i]);
}
void Converse(int A[],int n,int k)
{
Reverse(A,0,k-1);
Reverse(A,k,n-1);
Reverse(A,0,n-1);
}
void main()
{
int A[]={1,2,3,4,5};
cout<<"before converse ,the data are:";
for(int i=0;i<5;i++)
{
cout<<A[i];
}
cout<<endl;
int r[];
r=Converse(A,5,1);
cout<<"after converse,the data are:";
for(int j=0;j<5;j++)
cout<<r[j];
cout<<endl;
}