fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n,p,temp;
  7. cin>>n>>p;
  8. int arr[n];
  9. for(int i=0;i<n;i++)
  10. {
  11. cin>>arr[i];
  12. }
  13. for(int i=p; i<n; i++)
  14. {
  15. temp=arr[i];
  16. arr[i]=arr[i+1];
  17. arr[i+1]=temp;
  18.  
  19. }
  20. arr[n+1]=NULL;
  21. for(int i=0;i<n-1;i++)
  22. {
  23. cout<<arr[i];
  24. }
  25. return 0;
  26. }
Success #stdin #stdout 0s 4364KB
stdin
5 3
1 2 3 4 5
stdout
1235