fork(2) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int t;
  9. cin >> t;
  10.  
  11. char a[1000000];
  12. for(int i = 0; i < t; i++)
  13. {
  14. cin >> a;
  15. for(int j = 0; a[j] != '\0'; j++)
  16. {
  17. for(int i = j+1; a[i] != '\0' ; i++)
  18. {
  19. if(a[j] < a[i])
  20. {
  21. j = i;
  22. }
  23. }
  24. cout << a[j];
  25. }
  26. cout << "\n";
  27. }
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 4668KB
stdin
2
klln
klldsnFFnLN
stdout
n
snnN