顺序表的就地逆置.cpp
来自「顺序表的就地逆置算法,文档中有程序实现算法的代码与可运行源程序」· C++ 代码 · 共 26 行
CPP
26 行
#include<iostream>
using namespace std;
#define N 10
void main()
{
int i,j,t;
int list[N] = {1,2,3,4,5,6,7,8,9,10};
cout<<"the previous order of the list is "<<endl;
for(i=0;i<N;i++)
cout<<list[i]<<" ";
cout<<endl;
for(i=0,j=N-1;i<j; i++, j--)
{
t= list[i];
list[i] = list[j];
list[j] = t;
}
cout<<"the current order of the list is "<<endl;
for(i=0;i<N;i++)
cout<<list[i]<<" ";
system("pause");
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?