fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. int array[] = { 0, 1 , 2 , 3 ,4 ,5 ,6};
  8.  
  9. for (int i = 0; i<7; ++i) {cout << array[i] << " ";}
  10. cout <<'\n';
  11.  
  12. std::rotate(array, array+1, array+7);
  13. for (int i = 0; i<7; ++i) {cout << array[i] << " ";}
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 
1 2 3 4 5 6 0