Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int minIdx;
- for (int i = 0; i < n; i++) {
- minIdx = i;
- for (int j = i + 1; j < n; j++)
- if (s[minIdx] > s[j]) minIdx = j;
- swap(s[i], s[minIdx]);
- }
- cout << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment