fork(3) download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. void display_permutation(std::size_t n)
  5. {
  6. std::string s = std::to_string(n);
  7. std::sort(s.begin(), s.end());
  8. do {
  9. std::cout << s << std::endl;
  10. } while (std::next_permutation(s.begin(), s.end()));
  11. }
  12.  
  13.  
  14. int main() {
  15. display_permutation(231);
  16. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
123
132
213
231
312
321