fork download
  1. #include <cstring>
  2. #include <iostream>
  3. #include<algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. srand(time(NULL));
  8. string my_str = "abcd";
  9. cout << "Initial string: " << my_str << endl;
  10. const char* letters = my_str.c_str();
  11. char x = letters[rand() % strlen(letters)];
  12. my_str.erase(remove(my_str.begin(), my_str.end(), x), my_str.end());
  13. cout << "Final string: " << my_str << '\n';
  14. sort(my_str.begin(), my_str.end());
  15. do {
  16. cout << my_str << '\n';
  17. } while (next_permutation(my_str.begin(), my_str.end()));
  18. int n = my_str.length();
  19. int count = 1, i;
  20. for (i = 1; i <= n; i++)
  21. count = count * i;
  22. cout << count;
  23. return 0;
  24.  
  25. }
  26.  
  27.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Initial string: abcd
Final string: abc
abc
acb
bac
bca
cab
cba
6