Skip to content

Commit

Permalink
Create Array Rotation.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugdha-Hazra authored Dec 21, 2020
1 parent 1cd0015 commit 85db0f5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Array Rotation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t>0)
{int p,j,i,n,k,a[9000000],temp,b[9000000];
cin>>n>>k;
for(i=0;i<n;i++)
{cin>>a[i];}
while(k>0)
{ b[0]=a[n-1];
for(i=0;i<n-1;i++)
{
b[i+1]=a[i];
}
for(i=0;i<n;i++)
{
a[i]=b[i];
}
k--;
}
for(i=0;i<n;i++)
{cout<<a[i]<<" ";}
cout<<"\n";
t--;
}
}

0 comments on commit 85db0f5

Please sign in to comment.