fork(1) download
  1. #include<iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. int main(){
  6. std::vector<int> v;
  7. int x;
  8. do {
  9. std::cin>>x;
  10. if (!x) break; // IT WASN'T HERE!!!
  11. v.push_back(x);
  12. } while (x);
  13.  
  14. int c = 0;
  15. bool s = false;
  16. do {
  17. std::rotate(v.begin(),v.begin()+1,v.end());
  18. c++;
  19. if (std::is_sorted(v.begin(),v.end())){
  20. s = true;
  21. }
  22. } while(!s && (c <= v.size()));
  23.  
  24. if (s){
  25. for(int y = 0; y <= v.size(); y++){
  26. std::cout<<v[y]<<" ";
  27. }
  28. }
  29. else {
  30. std::cout<<"False";
  31. }
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 3464KB
stdin
7 10 2 3 4 0
stdout
2 3 4 7 10 0