Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- //freopen("input.txt", "r", stdin);
- ios::sync_with_stdio(0);
- cin.tie(0), cout.tie(0);
- string s;
- int one = 0, two = 0, three = 0, i;
- cin >> s;
- for (i = 0; i < s.length(); i = i + 2) {
- switch (s[i]) {
- case '1':
- ++one;
- break;
- case '2':
- ++two;
- break;
- case '3':
- ++three;
- break;
- default:
- break;
- }
- }
- i = 0;
- while (one) {
- s[i] = '1';
- i += 2;
- --one;
- }
- while (two) {
- s[i] = '2';
- i += 2;
- --two;
- }
- while (three) {
- s[i] = '3';
- i += 2;
- --three;
- }
- cout << s << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement