Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Cyclically rotate an array by one
#include <bits/stdc++.h> using namespace std; int main() { //code int t; cin>>t; while(t--) { int n; cin>>n; vector<int>v(n); for(int i=0;i<n;i++) cin>>v[i]; int c=v[n-1]; int t=v[0]; int curr; for(int i=1;i<n;i++) { curr=v[i]; v[i]=t; t=curr; } v[0]=c; for(int i=0;i<n;i++) cout<<v[i]<<" "; cout<<endl; } return 0; }
run
|
edit
|
history
|
help
0
Sum of digits of number
shifting
Functions-Part I
Speed
Hello World
creating triangle using nested loop
Best buy/sell day in stock
single_digit
map sort
My billing system