fork download
  1. // Find the next lexicographically
  2. // greater permutation of a word
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. string s = { "gfg" };
  12. bool val
  13. = next_permutation(s.begin(),
  14. s.end());
  15. if (val == false)
  16. cout << "No Word Possible"
  17. << endl;
  18. else
  19. cout << s << endl;
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 4176KB
stdin
Standard input is empty
stdout
ggf