• + 0 comments

    Another method for those who are concerned about manipulating existing array:

    for(int i=1;i<n+1;i++)
     {
         if(i<=n-d)
         {
             cout<<a[(i+d)-1]<<" ";
         }
         else
         {
            cout<<a[(i-n+d)-1]<<" ";
         }
     }