#include<iostream>
using namespace std;
void reverse(int* A, int lo, int hi)
{
while (lo < hi)
{
swap(A[lo++], A[hi--]);
}
}
void reverse(int* A, int n)
{
reverse(A, 0, n - 1);
}
int main()
{
int a[] = { 1,2,3,4,5,6,7,8,9,10 };
cout << "the reversed array is :";
for (int i = 0; i < sizeof(a) / sizeof(int); i++)
{
cout << a[i] << " ";
}
system("pause");
return 0;
}
010.数组倒置算法:迭代版
最新推荐文章于 2023-03-16 21:23:26 发布