1008

#include
#include
#include
#include

using namespace std;

int main()
{
    vector in_numbers;
    unsigned n = 1;
    unsigned m = 0;
    
    cin >> n >> m;
    m = m%n;                //m的移动次数可能会大于n!
    
    int tmp;
    for (int i = 0; i < n; ++i)
    {
        if(cin >> tmp)
        {
            in_numbers.push_back(tmp);
        }
    }

    vectorout_numbers;
    auto beg = out_numbers.end();
    auto p = in_numbers.begin();
    auto e = in_numbers.end();
    beg=out_numbers.insert(beg,p,(p+n-m));          //借助插入的操作实现移动!
    out_numbers.insert(beg, (p + n - m), e);

    int count_space = n - 1;
    for (auto r : out_numbers)
    {
        if (count_space > 0)
            cout << r << " ";
        else
        {
            cout << r;
        }
        --count_space;
    }

    system("pause");
    return 0;
}

你可能感兴趣的:(1008)