Skip to content

Commit

Permalink
Update Array Rotation.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugdha-Hazra authored Dec 22, 2020
1 parent 85db0f5 commit f8b6316
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion Array Rotation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{int t;
cin>>t;
while(t>0)
{
int n,k,a[1000000],b[1000000],i;
cin>>n>>k;
for(i=0;i<n;i++)
{ cin>>a[i];}
for(i=0;i<n;i++)
{
b[(i+k)%n]=a[i];
}
for(i=0;i<n;i++)
{
a[i]=b[i];
}

for(i=0;i<n;i++)
{
cout<<a[i]<<" ";
}cout<<"\n";
t--;
}
return 0;
}


/*#include<iostream>
using namespace std;
int main()
{
Expand Down Expand Up @@ -27,3 +57,4 @@ int main()
t--;
}
}
*/

0 comments on commit f8b6316

Please sign in to comment.