146


SUBMITTED BY: Guest

DATE: Dec. 25, 2013, 3:07 p.m.

FORMAT: Text only

SIZE: 330 Bytes

HITS: 2323

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. char id[51];
  8. while (scanf("%s", id) && id[0] != '#')
  9. {
  10. if (next_permutation(id, id+strlen(id)))
  11. printf("%s\n", id);
  12. else
  13. printf("No Successor\n");
  14. }
  15. return 0;
  16. }

comments powered by Disqus