fork download
  1. #include <algorithm>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. int main()
  6. {
  7. std::string str[4] = {"8563", "7385", "3857", "123"};
  8.  
  9. for (size_t i = 0; i < 4; i++) {
  10. std::string &s = str[i];
  11.  
  12. if (std::prev_permutation(s.begin(), s.end())) {
  13. std::cout << s << "\n";
  14. } else {
  15. std::cout << "None such!\n";
  16. }
  17. }
  18.  
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 4408KB
stdin
Standard input is empty
stdout
8536
7358
3785
None such!