顺序表中的数据的循环移动
#include <iostream>
#include <cstdlib>
using namespace std; int main()
{
int *data, n, x;
cin>>n; data = (int*)malloc(n*sizeof(int)); for (int i = ; i < n; ++i)
{
cin>>data[i];
} cin>>x;
if (x< || x > n)
{
cout<<"error!";
return ;
} for (int i = x; i <n; ++i)
{
cout<<data[i]<<" ";
} for (int i = ; i < x; ++i)
{
cout<<data[i]<<" ";
} return ;
}
注:顺序表本身并没有改变只是在输出顺序上做了点改变