fork(1) download
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4.  
  5. using namespace std;
  6.  
  7. #define b v.begin()
  8.  
  9. int main()
  10. {
  11. vector <int> v;
  12. int x, n=0;
  13.  
  14. for(;cin>>x;++n)
  15. v.push_back(x);
  16.  
  17. for(x=n;x--;rotate(b,b+1,b+n))
  18. if(is_sorted(b,b+n))
  19. {
  20. for(x:v) cout<<x<<' ';
  21. return 0;
  22. }
  23.  
  24. cout << '-';
  25. }
Success #stdin #stdout 0s 3416KB
stdin
7 10 2 3 4
stdout
2 3 4 7 10