• + 1 comment

    You're over-complicating things with two loops and C arrays in C++.

    int n, d;
    cin >> n >> d;
    vector<int> v((istream_iterator<int>(cin)), istream_iterator<int>());
    for (int i = 0; i < n; ++i) cout << v[(i + d) % n] << " ";