lina_os

Untitled

Nov 22nd, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5. int main() {
  6. int n;
  7. cin >> n;
  8. string s;
  9. cin >> s;
  10. int minIdx;
  11. for (int i = 0; i < n; i++) {
  12. minIdx = i;
  13. for (int j = i + 1; j < n; j++)
  14. if (s[minIdx] > s[j]) minIdx = j;
  15. swap(s[i], s[minIdx]);
  16. }
  17. cout << s;
  18.  
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment