text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt[4] = {0}; for (int i = 0; i < s.size(); i++) { if ('1' <= s[i] && s[i] <= '3') { ++cnt[s[i] - '0']; } } bool started(0); for (int k = 1; k <= 3; k++) { for (int m = 0; m < cnt[k]; m++) { if (started) { cout << "+"; } else { started = 1; } cout << k; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, a = 0, b = 0, c = 0; string s; cin >> s; for (i = 0; i < s.length(); i++) { if (s[i] == '1') a++; } for (i = 0; i < s.length(); i++) { if (s[i] == '2') b++; } for (i = 0; i < s.length(); i++) { if (s[i] == '3') c++; } for (i = 0; i < a - 1; i++) cout << "1+"; if (b == 0 && c == 0 && a != 0) cout << "1"; else if (a != 0) cout << "1+"; for (i = 0; i < b - 1; i++) cout << "2+"; if (c == 0 && b != 0) cout << "2"; else if (b != 0) cout << "2+"; for (i = 0; i < c - 1; i++) cout << "3+"; if (c != 0) cout << "3"; return 0; ; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; sort(s.begin(), s.end()); int n = s.size() / 2; string a; a = s[n]; for (int i = 0; i < n; i++) { a += s[i]; a += s[n + 1 + i]; } cout << a; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, j = 0, n, num[200], temp; cin >> s; for (i = 0; i < s.size(); i = i + 2) { j = j + 1; if (s[i] == '1') num[j] = 1; else if (s[i] == '2') num[j] = 2; else if (s[i] == '3') num[j] = 3; } n = j; for (i = 1; i <= n - 1; i++) for (j = 1; j <= n - i; j++) { if (num[j] > num[j + 1]) { temp = num[j]; num[j] = num[j + 1]; num[j + 1] = temp; } } cout << num[1]; for (i = 2; i < n; i++) cout << "+" << num[i]; if (n != 1) cout << "+" << num[n]; }
#include <bits/stdc++.h> using namespace std; int main() { string num; cin >> num; for (int i = 0; i < num.size() - 1; i += 2) { for (int j = 0; j < num.size() - i - 2; j += 2) { if (num[j] > num[j + 2]) { char temp = num[j]; num[j] = num[j + 2]; num[j + 2] = temp; } } } cout << num; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; long long sl = s.length(); long long one = 0; long long two = 0; long long three = 0; long long i; for (i = 0; i < sl; i = i + 2) { if (s[i] - '0' == 1) { one++; } else if (s[i] - '0' == 2) { two++; } else { three++; } } vector<char> v; for (i = 0; i < one; i++) { v.push_back('1'); v.push_back('+'); } for (i = 0; i < two; i++) { v.push_back('2'); v.push_back('+'); } for (i = 0; i < three; i++) { v.push_back('3'); v.push_back('+'); } if (v[v.size() - 1] == '+') { for (i = 0; i < v.size() - 1; i++) { cout << v[i]; } } else { for (i = 0; i < v.size(); i++) { cout << v[i]; } } return 0; }
#include <bits/stdc++.h> int main() { char a[100]; int temp, len, i, j; gets(a); len = strlen(a); for (i = 0; i < len; i += 2) { for (j = i + 2; j < len; j += 2) { if (a[i] >= a[j]) { temp = a[j]; a[j] = a[i]; a[i] = temp; } } } printf("%s", a); printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); int c1 = 0, c2 = 0, c3 = 0; int n = s.length(); for (int i = 0; i < n; i++) { if (s[i] == '1') c1++; else if (s[i] == '2') c2++; else c3++; i++; } string s2; while (c1 > 0) { s2 += "1+"; c1--; } while (c2 > 0) { s2 += "2+"; c2--; } while (c3 > 0) { s2 += "3+"; c3--; } s2.resize(s2.size() - 1); cout << s2; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; vector<char> v, v1; for (int i = 0; i < str.length(); i += 2) { v.push_back(str[i]); } sort(v.begin(), v.end()); for (int i = 0; i < v.size() - 1; i++) { v1.push_back(v[i]); v1.push_back('+'); } v1.push_back(v[v.size() - 1]); for (int i = 0; i < v1.size(); i++) cout << v1[i]; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int temp = 0; cin >> s; for (int i = 0; i < s.length(); i++) { for (int j = i + 1; j < s.length(); j++) { if (s[i] > s[j] && s[j] != '+') { temp = s[i]; s[i] = s[j]; s[j] = temp; } } } cout << s; }
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; sort(a.begin(), a.end()); for (int i = 0; i < a.size(); i++) { if (a[i] != '+') { cout << a[i]; if (i != a.size() - 1) { cout << '+'; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int i, n, p; vector<int> v; string s, s1; int j, m, a[52]; bool x = false; int main() { cin >> s; for (i = 0; i < s.size(); i += 2) { v.push_back(s[i] - '0'); } sort(v.begin(), v.end()); cout << v[0]; for (i = 1; i < v.size(); i++) { cout << '+' << v[i]; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int i = 0; i < s.size(); i += 2) { for (int j = 0; j < i; j++) { if (s[i] < s[j]) { swap(s[i], s[j]); } } } cout << s << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string inpt, outpt = ""; vector<char> digits; getline(cin, inpt); for (int i = 0; i < inpt.size(); i++) { if (inpt[i] != '+') { digits.push_back(inpt[i]); } } sort(digits.begin(), digits.end()); for (int i = 0; i < digits.size() - 1; i++) { outpt += digits[i]; outpt += '+'; } outpt += digits[digits.size() - 1]; cout << outpt << endl; return 0; }
#include <bits/stdc++.h> using namespace std; char s[105]; int a[105]; int main() { gets(s); int len = strlen(s); s[len] = '+'; s[len + 1] = '\0'; int sum = 0, l = 0; for (int i = 0; s[i]; i++) { if (s[i] == '+') a[l++] = sum, sum = 0; else sum *= 10, sum += s[i] - '0'; } sort(a, a + l); for (int i = 0; i < l; i++) { printf("%d", a[i]); if (i != l - 1) printf("+"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { vector<int> arr; string s; cin >> s; for (int i = 0; i != s.size(); i++) { if (s[i] != '+') arr.push_back(s[i] - '0'); } sort(arr.begin(), arr.end()); for (int i = 0; i != arr.size(); ++i) { if (i) cout << "+"; cout << arr[i]; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int x = s.size() - 1; sort(s.begin(), s.end()); for (int i = x / 2; i < x; i++) cout << s[i] << "+"; cout << s[x] << endl; return 0; }
#include <bits/stdc++.h> int main() { char a, s[100]; int i, j; gets(s); for (i = 0; (s[i] != '\0') && (s[i + 1] != '\0'); i += 2) { for (j = 0; (s[j] != '\0') && (s[j + 1] != '\0'); j += 2) { if (s[j] > s[j + 2]) { a = s[j]; s[j] = s[j + 2]; s[j + 2] = a; } } } puts(s); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = (s.length() / 2) + 1; int arr[n]; int cnt = 0; for (int i = 0; i < s.length(); i += 2) { arr[cnt] = s[i] - '0'; cnt++; } sort(arr, arr + n); cout << arr[0]; for (int i = 1; i < n; ++i) { cout << "+" << arr[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; vector<char> v; int main() { string s; cin >> s; for (int(i) = (0); (i) < (s.size()); ++(i)) { if (s[i] != '+') { v.push_back(s[i]); } } sort(v.begin(), v.end()); for (int(i) = (0); (i) < (v.size()); ++(i)) { if (i + 1 == v.size()) { cout << v[i]; } else cout << v[i] << "+"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, j, len, counter; string a; char temp; while (cin >> a) { counter = 1; len = a.size(); for (i = 0; i < len - 2; i += 2) for (j = 0; j < len - 2 - i; j += 2) { if (a[j] > a[j + 2]) { temp = a[j]; a[j] = a[j + 2]; a[j + 2] = temp; } } for (i = 0; i < len; i += 2) { if (counter > 1) cout << '+'; counter++; cout << a[i]; } cout << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { string s1; cin >> s1; vector<int> v; int j = 0; for (int i = 0; i < s1.size(); i += 2) v.push_back(s1[i] - 48); sort(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { cout << v.at(i); if (i != v.size() - 1) cout << "+"; } cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a1 = 0, a2 = 0, a3 = 0; for (int i = 0; i < s.length(); i += 2) { if (s[i] == '1') a1++; else if (s[i] == '2') a2++; else a3++; } if (a1 > 0) { cout << 1; for (int i = 1; i < a1; i++) { cout << "+" << 1; } } if (a1 == 0 && a2 > 0) { cout << 2; for (int i = 1; i < a2; i++) { cout << "+" << 2; } } else { for (int i = 0; i < a2; i++) { cout << "+" << 2; } } if (a1 == 0 && a2 == 0 && a3 > 0) { cout << 3; a3--; } for (int i = 0; i < a3; i++) { cout << "+" << 3; } }
#include <bits/stdc++.h> using namespace std; int main() { char s[200]; while (~scanf("%s", s)) { vector<char> vec; for (int i = 0; s[i]; i++) { if (s[i] == '+') continue; vec.push_back(s[i]); } sort(vec.begin(), vec.end()); printf("%c", vec[0]); for (int i = 1; i < vec.size(); i++) printf("+%c", vec[i]); puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int problem[101]; string problemS; cin >> problemS; for (uint16_t counter = 0; counter < (problemS.length() + 1) / 2; counter++) { problem[counter] = (int)problemS[counter * 2] - ('1' - 1); } sort(problem, problem + ((problemS.length() + 1) / 2)); for (uint16_t counter = 0; counter < (problemS.length() + 1) / 2; counter++) { cout << problem[counter]; if (counter != ((problemS.length() + 1) / 2) - 1) { cout << "+"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c, i, l, v; string s; getline(cin, s); l = s.length(); for (i = 0; i < l - 2; i++) { for (int j = 0; j < l - 1; j = j + 2) { if (s[j] > s[j + 2]) { int t = s[j]; s[j] = s[j + 2]; s[j + 2] = t; } } } cout << s; return 0; }
#include <bits/stdc++.h> int main() { char a[101]; scanf("%s", a); int i; int n = 101; while (n > 0) { for (i = 0; a[i + 2] != '\0'; i++) { if (i % 2 == 0) { char temp; if (a[i] > a[i + 2]) { temp = a[i]; a[i] = a[i + 2]; a[i + 2] = temp; } } } n--; } for (i = 0; a[i] != '\0'; i++) { printf("%c", a[i]); } return 0; }
#include <bits/stdc++.h> int main() { #pragma comment(linker, "/STACK:67108864") char c[107]; int i, d = 0, f = 0, g = 0, s; gets(c); s = strlen(c); for (i = 0; i < s; i++) { if (c[i] == '1') { d = d + 1; } if (c[i] == '2') { f = f + 1; } if (c[i] == '3') { g = g + 1; } } for (i = 0; i < d; i++) { if (i != d - 1) { printf("1+"); } else { printf("1"); } } if (f != 0 && d != 0 || d != 0 && g != 0) { printf("+"); } for (i = 0; i < f; i++) { if (i != f - 1) { printf("2+"); } else { printf("2"); } } if (g != 0 && f != 0) { printf("+"); } for (i = 0; i < g; i++) { if (i != g - 1) { printf("3+"); } else { printf("3"); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); string h = ""; for (int i = 0; i < n; i += 2) { char c = s[i]; h.push_back(c); } sort(h.begin(), h.end()); if (n > 1) { for (int i = 0; i < h.length(); i++) { if (i < h.length() - 1) { cout << h[i] << "+"; } else { cout << h[i]; } } cout << endl; } else cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { string a, b; cin >> a; for (char i : a) { if (i != '+') b += i; } sort(b.begin(), b.end()); for (int i = 0; i < b.size() - 1; i++) { cout << b[i] << "+"; } cout << b[b.size() - 1]; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a[50]; int count = 0; for (int j = 0; j < s.length(); j += 2) { a[count] = s.at(j) - '0'; count++; } for (int i = 0; i < count; i++) for (int j = i + 1; j < count; j++) if (a[j] < a[i]) { int temp = a[j]; a[j] = a[i]; a[i] = temp; } for (int i = 0; i < count - 1; i++) cout << a[i] << '+'; cout << a[count - 1] << endl; }
#include <bits/stdc++.h> int main() { char temp; char a[100]; gets(a); int i, j; if (a[1] == '\0') printf(a); else { for (i = 0; i < strlen(a) / 2 + 1; i++) { for (j = 0; j < strlen(a) - 2; j = j + 2) { if (a[j + 2] < a[j]) { temp = a[j]; a[j] = a[j + 2]; a[j + 2] = temp; } } } printf(a); } }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); vector<char> arr; for (int i = 0; i < l; i++) { if (s[i] != '+') arr.push_back(s[i]); } sort(arr.begin(), arr.end()); for (int i = 0; i < arr.size() - 1; i++) { cout << arr[i] << '+'; } cout << arr[arr.size() - 1]; }
#include <bits/stdc++.h> using namespace std; int main() { string s; vector<char> v; cin >> s; int l = s.size(), i; for (i = 0; i < l; i++) { if (s[i] == '1' || s[i] == '2' || s[i] == '3') v.push_back(s[i]); } sort(v.begin(), v.end()); cout << v[0]; for (i = 1; i < v.size(); i++) cout << "+" << v[i]; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i; vector<int> v1; for (i = 0; i < s.length(); i++) { if (i % 2) { } else { int d = s[i]; v1.push_back(d - 48); } } sort(v1.begin(), v1.end()); for (i = 0; i < v1.size() - 1; i++) { cout << v1[i] << "+"; } int l = v1.size(); cout << v1[l - 1]; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; for (int i = 0; i < s.length(); i += 2) { for (int j = 0; j < s.length(); j += 2) if (s[i] < s[j]) swap(s[i], s[j]); } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int n = s.length(); int n1 = 0, n2 = 0, n3 = 0, n4; for (int i = 0; i < n; i++) { if (s[i] == '1') n1 += 1; if (s[i] == '2') n2 += 1; if (s[i] == '3') n3 += 1; if (s[i] == '+') n4 += 1; } for (int j = 1; j <= n1; j++) { cout << 1; if (n4 > 0) { cout << '+'; --n4; } } for (int j = 1; j <= n2; j++) { cout << 2; if (n4 > 0) { cout << '+'; --n4; } } for (int j = 1; j <= n3; j++) { cout << 3; if (n4 > 0) { cout << '+'; --n4; } } }
#include <bits/stdc++.h> using namespace std; int main(int argc, char *argv[]) { string s; int one = 0, two = 0, thr = 0, i, n; cin >> s; for (i = 0; i < s.length(); i = i + 2) { if (s[i] == '1') { one++; } else if (s[i] == '2') { two++; } else thr++; } n = one + two + thr; n--; while (one--) { printf("1"); if (n != 0) { printf("+"); n--; } } while (two--) { printf("2"); if (n != 0) { printf("+"); n--; } } while (thr--) { printf("3"); if (n != 0) { printf("+"); n--; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(); sort(s.begin(), s.end()); s.erase(0, l / 2); for (int i = 0; i < l / 2; i++) { cout << s[i] << '+'; } cout << s[(l / 2)]; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string x; cin >> x; sort(x.begin(), x.end()); for (int i = 0; i < x.size(); ++i) { if (isdigit(x[i])) { if (i != x.size() - 1) { cout << x[i] << "+"; } else { cout << x[i]; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string str; int c1, c2, c3; c1 = c2 = c3 = 0; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == '+') { str.erase(i, 1); i--; } } for (int i = 0; i < str.length(); i++) { if (str[i] == '1') c1++; else if (str[i] == '2') c2++; else c3++; } if (c1 == 0) { if (c2 == 0) { if (c3 == 0) cout << ""; else { cout << "3"; for (int i = 0; i < c3 - 1; i++) { cout << "+3"; } } } else { if (c3 == 0) { cout << "2"; for (int i = 0; i < c2 - 1; i++) { cout << "+2"; } } else { cout << "2"; for (int i = 0; i < c2 - 1; i++) { cout << "+2"; } for (int i = 0; i < c3; i++) { cout << "+3"; } } } } else { cout << "1"; for (int i = 0; i < c1 - 1; i++) { cout << "+1"; } if (c2 == 0) { if (c3 == 0) cout << ""; else { for (int i = 0; i < c3; i++) { cout << "+3"; } } } else { if (c3 == 0) { for (int i = 0; i < c2; i++) { cout << "+2"; } } else { for (int i = 0; i < c2; i++) { cout << "+2"; } for (int i = 0; i < c3; i++) { cout << "+3"; } } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int l, i, j; char s[100]; scanf("%s", s); l = strlen(s); for (i = 0; i < l; i += 2) { for (j = 0; j < l - i - 2; j += 2) { if (s[j] > s[j + 2]) { swap(s[j], s[j + 2]); } } } printf("%s", s); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; sort(s.begin(), s.end()); if (s.size() != 1) for (long long i = (s.size() - 1) / 2; i <= s.size() - 2; i++) { cout << s[i] << "+"; } cout << s[s.size() - 1]; }
#include <bits/stdc++.h> using namespace std; int n; string str, st; int a[110]; int main() { int x = 0; cin >> str; vector<int> s; for (int i = 0; i < str.size(); i++) { if (str[i] <= '9' && str[i] >= '0') s.push_back(str[i] - '0'); } sort(s.begin(), s.end()); cout << s[0]; for (int i = 1; i < s.size(); i++) cout << "+" << s[i]; cout << endl; return 0; }
#include <bits/stdc++.h> int main() { int a[4] = {0}, i, j; char s[110]; scanf("%s", s); int n = strlen(s); for (i = 0; i < n; i += 2) { if (s[i] == '1') a[1]++; if (s[i] == '2') a[2]++; if (s[i] == '3') a[3]++; } int temp = 1; i = 0; while (temp <= 3) { while (a[temp]--) { s[i] = temp + 48; i += 2; } temp++; } printf("%s", s); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string ch; int i, l, c1 = 0, c2 = 0, c3 = 0; cin >> ch; l = ch.length(); for (i = 0; i < l; i++) { if (ch[i] == '1') { c1++; } else if (ch[i] == '2') { c2++; } else if (ch[i] == '3') { c3++; } } for (i = 0; i < c1; i++) { cout << '1'; if ((c2 == 0 && c3 == 0) && i == c1 - 1) { cout << endl; } else { cout << '+'; } } for (i = 0; i < c2; i++) { cout << '2'; if (i == c2 - 1 && c3 == 0) { cout << endl; } else { cout << '+'; } } for (i = 0; i < c3; i++) { cout << '3'; if (i == c3 - 1) { cout << endl; } else { cout << '+'; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char ch[105]; cin >> ch; int cnt1 = 0, cnt2 = 0, cnt3 = 0; for (int i = 0; i < strlen(ch); i = i + 2) { if (ch[i] == '1') cnt1++; else if (ch[i] == '2') cnt2++; else cnt3++; } int cnt4 = 0, sum = cnt1 + cnt2 + cnt3; for (int i = 0; i < cnt1; i++) { cout << 1; cnt4++; if (cnt4 == sum) break; cout << "+"; } for (int i = 0; i < cnt2; i++) { cout << 2; cnt4++; if (cnt4 == sum) break; cout << "+"; } for (int i = 0; i < cnt3; i++) { cout << 3; cnt4++; if (cnt4 == sum) break; cout << "+"; } return 0; }
#include <bits/stdc++.h> int main() { char a[100]; int l, t; scanf("%s", &a); l = strlen(a); for (int i = 0; i < l - 2; i += 2) for (int j = i + 2; j < l; j += 2) { if (a[i] > a[j]) { t = a[i]; a[i] = a[j]; a[j] = t; } } printf("%s\n", a); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string cad; cin >> cad; vector<char> ns; for (int i = 0; i < (int)cad.size(); i++) { if (isdigit(cad[i])) ns.push_back(cad[i]); } sort(ns.begin(), ns.end()); for (int i = 0; i < (int)ns.size(); i++) { cout << ns[i] << (i + 1 < (int)ns.size() ? "+" : "\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int x[100]; string a; int y = 0; cin >> a; for (size_t i = 0; i < a.length(); i++) { if (a[i] == '1') { x[y] = 1; y++; } if (a[i] == '2') { x[y] = 2; y++; } if (a[i] == '3') { x[y] = 3; y++; } } sort(x, x + y); for (size_t i = 0; i < y; i++) { if (i == y - 1) { cout << x[i]; break; } cout << x[i] << "+"; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { char a[1000], b[1000], l, j = 0; cin >> a; l = strlen(a); for (int i = 0; i < l; i++) { if (a[i] > 47 && a[i] < 58) { b[j] = a[i]; j++; } } sort(b, b + j); for (int i = 0; i < j; i++) { if (i == j - 1) { cout << b[i]; } else { cout << b[i] << "+"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string array; getline(cin, array); char num[array.length() + 1]; int x = 0; for (int i = 0; i < array.length(); i++) { if (array[i] == '+' || array[i] == '\n' || array[i] == ' ') { continue; } else { num[x] = array[i]; x++; } } for (int i = 0; i < x; i++) { for (int j = 0; j < x - i - 1; j++) { if (int(num[j]) > int(num[j + 1])) { char temp = num[j]; num[j] = num[j + 1]; num[j + 1] = temp; } } } for (int i = 0; i < x; i++) { if (i == x - 1) { cout << num[i] << endl; } else { cout << num[i] << "+"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<char> v; for (int i = 0; i < int(s.size()); i += 2) { v.push_back(s[i]); } sort(v.begin(), v.end()); for (int i = 0; i < int(v.size()); i++) { if (i != v.size() - 1) { cout << v[i] << "+"; } else { cout << v[i]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string input; cin >> input; int A[100]; int x = 0; for (int i = 0; i < input.length(); i++) { if (input[i] != '+') { A[x] = input[i] - 48; x++; } } sort(A, A + x); cout << A[0]; for (int i = 1; i < x; i++) { cout << "+" << A[i]; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { string a, x = ""; int c = 0; cin >> a; for (int i = 0; i < a.size(); i++) { if (a[i] == '+') { c++; } else x += a[i]; } sort(x.begin(), x.end()); for (int i = 0; i < (a.size() - c); i++) { if (i == (a.size() - c - 1)) cout << x[i] << endl; else cout << x[i] << "+"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a[101], n, i, j, k = 1, max, t, r; char str[101]; scanf("%s", &str); r = strlen(str); for (i = 0; i < r; i++) if (str[i] >= 49 && str[i] <= 51) { a[k] = str[i] - 48; k++; } for (i = k - 1; i >= 2; i--) { max = a[i]; t = i; for (j = i - 1; j >= 1; j--) if (a[j] > max) { max = a[j]; t = j; } if (t != i) swap(a[i], a[t]); } for (i = 1; i < k - 1; i++) printf("%d+", a[i]); printf("%d\n", a[k - 1]); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; string s1; cin >> s; vector<int> v; long int i; int a; for (i = 0; i < s.size(); i++) { if (s[i] == '1') { s1 = s[i]; a = stoi(s1); v.push_back(a); s1.clear(); } else if (s[i] == '2') { s1 = s[i]; a = stoi(s1); v.push_back(a); s1.clear(); } else if (s[i] == '3') { s1 = s[i]; a = stoi(s1); v.push_back(a); s1.clear(); } } sort(v.begin(), v.end()); for (i = 0; i < v.size() - 1; i++) cout << v[i] << "+"; cout << v[v.size() - 1]; }
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; vector<int> v; for (int i = 0; str[i] != '\0'; i++) { if (str[i] != '+') v.push_back(((int)str[i]) - 48); } sort(v.begin(), v.end()); for (auto iter = v.begin(); iter != v.end() - 1; iter++) { cout << *iter << "+"; } cout << *(v.end() - 1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a = 0, b = 0, c = 0; int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == '1') { a++; } else if (s[i] == '2') { b++; } else if (s[i] == '3') { c++; } } if (n == 1) { cout << s; } else { while (a--) { cout << 1; if (a == 0 && b == 0 && c == 0) { } else cout << "+"; } a = 0; while (b--) { cout << 2; if (a == 0 && b == 0 && c == 0) { } else cout << "+"; } b = 0; while (c--) { cout << 3; if (a == 0 && b == 0 && c == 0) { } else cout << "+"; } } }
#include <bits/stdc++.h> using namespace std; int main() { string num; cin >> num; int freq[100000] = {}; for (int i = 0; i < num.size(); i++) { freq[num[i]]++; } int j = 0; for (char i = '1'; i <= '3'; i++) { while (freq[i] > 0) { if (j != 0) { cout << "+"; } cout << i; freq[i]--; j++; } } return 0; }
#include <bits/stdc++.h> using namespace std; vector<char> ans; int main() { int a = 0, b = 0, c = 0; string s; cin >> s; for (int i = 0; i < s.size(); i += 2) { if (s[i] == '1') a++; if (s[i] == '2') b++; if (s[i] == '3') c++; } for (int i = 0; i < a; i++) { ans.push_back('+'); ans.push_back('1'); } for (int i = 0; i < b; i++) { ans.push_back('+'); ans.push_back('2'); } for (int i = 0; i < c; i++) { ans.push_back('+'); ans.push_back('3'); } for (int i = 1; i < ans.size(); i++) cout << ans[i]; return 0; return 0; }
#include <bits/stdc++.h> using namespace std; multiset<int> Set; multiset<int>::iterator it, tmp; int sum, n; string s; char c; int main() { ios_base::sync_with_stdio(false); cin >> s; for (int i = 0; i < s.size(); ++i) { c = s[i]; if (c != '+') sum = sum * 10 + (c - '0'); else { Set.insert(sum); sum = 0; ++n; } } Set.insert(sum); for (it = Set.begin(); it != Set.end(); ++it) { cout << *it; --n; if (n >= 0) cout << '+'; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e3; char s[MAXN]; int a[MAXN]; int main(void) { scanf("%s", s); int n = strlen(s), m = 0; for (int i = 0; i < n; i += 2) a[m++] = s[i] - '0'; sort(a, a + m); printf("%d", a[0]); for (int i = 1; i < m; i++) printf("+%d", a[i]); return 0; }
#include <bits/stdc++.h> using namespace std; set<char> st; priority_queue<int> pq; vector<char> v; int main() { string s; cin >> s; for (int(i) = (0); (i) < (s.length()); (i)++) { if (s[i] != '+') v.push_back(s[i]); } sort(v.begin(), v.end()); for (int(i) = (0); (i) < (v.size()); (i)++) { printf("%c", v[i]); if (i != v.size() - 1) { printf("+"); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string input; cin >> input; bool flag = 0; if (input.length() == 1) flag = 1; for (int j = 0; j < input.length() && flag == 0; j++) { for (int i = 0; i < input.length() - 2; i += 2) if (input[i] > input[i + 2]) swap(input[i], input[i + 2]); } cout << input << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int sum = 0; string s; cin >> s; multiset<int> n; for (int i = 0; i < s.size(); i++) { if (s[i] >= '0' && s[i] <= '9') n.insert((s[i] - '0')); else sum++; } for (auto v : n) { cout << v; if (sum) { cout << '+'; sum--; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string x; cin >> x; std::vector<long long> ans; for (long long int i = 0; i < x.length(); i++) { if (x[i] != '+') ans.push_back(int(x[i] - '0')); } sort((ans).begin(), (ans).end()); for (long long int i = 0; i < ans.size(); i++) { cout << ans[i]; if (i != ans.size() - 1) cout << "+"; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i = 0, x = 0; vector<int> no; while (i < s.size()) { if (s[i] == '1') x = 1; else if (s[i] == '2') x = 2; else if (s[i] == '3') x = 3; no.push_back(x); i += 2; } sort(no.begin(), no.end()); i = 0; while (i < no.size()) { cout << no[i]; if (i != (no.size() - 1)) cout << '+'; ++i; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int cnt = 0; int n = s.length(); string x = ""; for (int i = 0; i < n; i++) { if (s[i] != '+') { x += s[i]; cnt++; } } sort(x.begin(), x.end()); string::iterator it; int j = 1; cnt--; while (cnt--) { it = x.insert(x.begin() + j, '+'); j += 2; } cout << x; }
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; int n = a.length(); sort(a.begin(), a.end()); int m = (n - 1) / 2; a.erase(0, m); cout << a[0]; for (int i = 1; i < n - m; i++) { cout << "+" << a[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { string n; cin >> n; vector<int> a; for (int i = 0; i < n.size(); i += 2) { a.push_back(n[i] - 48); } sort(a.begin(), a.end()); for (int i = 0; i < a.size() - 1; ++i) { cout << a[i] << "+"; } cout << a[a.size() - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; vector<int> a; cin >> s; for (int i = 0; i < s.length(); i += 2) a.push_back(s[i] - '0'); sort(a.begin(), a.end()); for (int i = 0; i < int(a.size() - 1); i++) cout << a[i] << "+"; cout << a[a.size() - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; int i, l = 0, c, p; bool flag = 0; cin >> s; while (s[l] != '\0') { l++; } p = s[0] - 48; for (i = 0; i < l; i = i + 2) { c = s[i] - 48; if (c > p) continue; if ((c == p) || c < p) { flag = 1; int j, temp[(l + 1) / 2]; for (j = 0; j < l; j = j + 2) { temp[(j + 1) / 2] = s[j] - 48; } sort(temp, temp + (l + 1) / 2); for (j = 0; j < l; j = j + 2) { s[j] = temp[(j + 1) / 2] + 48; } break; } p = c; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; sort(s.begin(), s.end()); for (int i = s.size() / 2; i < s.size(); i++) { cout << s[i]; if (i == s.size() - 1) ; else { cout << "+"; } } }
#include <bits/stdc++.h> using namespace std; int main() { string str, new_str = ""; vector<char> vect; cin >> str; for (int i = 0; i < str.size(); i++) if (str[i] == '1' || str[i] == '2' || str[i] == '3') vect.push_back(str[i]); sort(vect.begin(), vect.end()); for (int i = 0; i < vect.size(); i++) { if (i != vect.size() - 1) { new_str += vect[i]; new_str += '+'; } else new_str += vect[i]; } cout << new_str << endl; }
#include <bits/stdc++.h> using namespace std; int main(void) { bool flag1 = true, flag2 = true, flag3 = true; string input; string count_1 = "", count_2 = "", count_3 = ""; cin >> input; for (int i = 0; i < input.length(); i++) { switch (input[i]) { case '1': if (flag1) { flag1 = false; } else { count_1 += "+"; } count_1 += "1"; break; case '2': if (flag2) { flag2 = false; } else { count_2 += "+"; } count_2 += "2"; break; case '3': if (flag3) { flag3 = false; } else { count_3 += "+"; } count_3 += "3"; break; default: continue; } } if (!flag1 && !flag2) count_1 += "+"; if ((!flag1 && !flag3) || (!flag2 && !flag3)) count_2 += "+"; cout << count_1 << count_2 << count_3 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[1001], i, j, m; char c; int main() { while (c != '\n') { scanf("%c", &c); if (c == '1' || c == '2' || c == '3') { a[c - '0']++; m = max(m, c - '0'); } } for (i = 1; i <= 3; i++) for (j = 1; j <= a[i]; j++) { printf("%d", i); if (i != m || j != a[i]) printf("+"); } return 0; }
#include <bits/stdc++.h> using namespace std; void count(char *s, int *c) { while (*s != '\0') { ++c[*s - '0']; s += 2; } } void sort(char *s, int *c) { for (int i = 1; i <= 3; ++i) { for (int j = 0; j < c[i]; ++j) { *s = '0' + i; s += 2; } } } int main(void) { ios_base::sync_with_stdio(false); int c[4] = {0}; char s[105]; cin >> s; count(s, c); sort(s, c); cout << s; return 0; }
#include <bits/stdc++.h> int main() { int j, k; char a[100]; scanf("%s", a); for (int i = 2; i < strlen(a); i += 2) { k = a[i]; j = i - 2; while (j >= 0 && a[j] > k) { a[j + 2] = a[j]; j = j - 2; } a[j + 2] = k; } printf("%s", a); }
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; vector<int> a; for (int i = 0; i < str.size(); i++) if (str[i] != '+') a.push_back(str[i] - 48); sort(a.begin(), a.end()); int j = 0; for (int i = 0; i < a.size(); i++) { str[j] = a[i] + 48; j += 2; } cout << str; return 0; }
#include <bits/stdc++.h> using namespace std; const int sz = 100010; vector<long long> v(sz, 0), prefix(sz, 0), suffix(sz, 0); string s; int main() { int n; string s, temp = ""; cin >> s; for (int i = 0; i < s.length(); i += 2) { temp.push_back(s[i]); } sort(temp.begin(), temp.end()); int k = 0; for (int i = 0; i < s.length(); i += 2, ++k) { s[i] = temp[k]; } cout << s; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int a[5] = {0}; for (int i = 0; i < s.length(); i += 2) a[s[i] - '0']++; int count = 0; for (int i = 1; i <= 3; i++) { for (int j = 1; j <= a[i]; j++) { cout << i; count++; if (count < s.length() / 2 + 1) cout << "+"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; vector<string> tokens; stringstream stream(s); string temp; while (getline(stream, temp, '+')) { tokens.push_back(temp); } sort(tokens.begin(), tokens.end()); temp = ""; for (auto i = 0; i < tokens.size(); i++) { if (i != tokens.size() - 1) temp += tokens[i] + '+'; else temp += tokens[i]; } cout << temp << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int arr[100] = {0}, con = 0, d = 0; ; string x; cin >> x; for (int i = 0; i < x.size(); i++) { if (x[i] == '+') { for (int j = 0; j < con; j++) { arr[d] += (x[i - j - 1] - 48) * pow(10, j); } d++; con = 0; } else con++; } for (int j = 0; j < con; j++) { arr[d] += (x[x.size() - j - 1] - 48) * pow(10, j); } sort(arr, arr + d + 1); for (int j = 0; j <= d; j++) { if (j == d) cout << arr[j]; else cout << arr[j] << "+"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int l = s.length(), a[3] = {0}; for (int i = 0; i < l; i++) { if (s[i] == '1') { a[0]++; i++; } else if (s[i] == '2') { a[1]++; i++; } else if (s[i] == '3') { a[2]++; i++; } } for (int i = 0; i < 3; i++) { while (a[i] > 0) { cout << i + 1; l = l - 2; if (l > 0) cout << "+"; a[i]--; } } return 0; }
#include <bits/stdc++.h> int main() { int i, j, min; char temp; std::string input{}; std::getline(std::cin, input); if (input.length() == 1) { std::cout << input[0]; exit(0); } for (i = 0; i <= input.length() - 3; i += 2) { min = i; for (j = i + 2; j <= input.length() - 1; j += 2) { if (input[j] < input[min]) min = j; } temp = input[min]; input[min] = input[i]; input[i] = temp; } for (i = 0; i <= input.length() - 1; i++) std::cout << input[i]; return 0; }
#include <bits/stdc++.h> using namespace std; void sortString(string &str) { sort(str.begin(), str.end()); int size = str.length(); for (int i = 0; i < size - 1; i++) { cout << str[i] << "+"; } cout << str[size - 1] << "\n"; } int main() { ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); string str; cin >> str; str.erase(remove(str.begin(), str.end(), '+'), str.end()); sortString(str); return 0; }
#include <bits/stdc++.h> using namespace std; int sum_of_digits(int num) { int sum = 0; while (num) { sum += num % 10; num = num / 10; } return sum; } int main() { string a = "123"; string str; cin >> str; for (int i = 0; i < str.length(); i += 2) { int min = i; for (int j = i + 2; j < str.length(); j += 2) { if (str[j] < str[min]) min = j; } char temp = str[min]; str[min] = str[i]; str[i] = temp; } cout << str; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int i, j; int n = s.size(); for (i = 0; i < n; i = i + 2) { for (j = 0; j < n - i - 2; j = j + 2) { if (s[j] > s[j + 2]) { swap(s[j], s[j + 2]); } } } cout << s; return 0; }
#include <bits/stdc++.h> int main() { char str[100]; scanf("%s", str); int len = strlen(str); int i, j, count; int ara[len / 2 + 1]; for (i = 0, count = 0, j = 0; i < len; i += 2, j++, count++) { ara[j] = str[i] - 48; } for (i = 0; i < count; i++) { for (int j = i + 1; j < count; j++) { if (ara[i] > ara[j]) { int t = ara[i]; ara[i] = ara[j]; ara[j] = t; } } } for (i = 0; i < count; i++) { if (i == 0) { printf("%d", ara[i]); } else { printf("+%d", ara[i]); } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string a; cin >> a; vector<long long> v; for (int i = 0; i < a.length(); i += 2) { a[i] = a[i] - '0'; v.push_back(a[i]); } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { cout << v[i]; if (i != v.size() - 1) cout << "+"; } }
#include <bits/stdc++.h> using namespace std; int main() { string a; int A[100]; int n = 0; cin >> a; for (int i = 0; i < a.size(); i++) { if (a[i] == '1') { A[n] = 1; n++; } else if (a[i] == '2') { A[n] = 2; n++; } else if (a[i] == '3') { A[n] = 3; n++; } } int SIZE; if (n == 1) SIZE = 1; else if (n > 1) SIZE = n + 1; sort(A, A + SIZE); for (int i = 0; i < n - 1; i++) cout << A[i] << "+"; cout << A[n - 1]; return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; void ha() { string s; cin >> s; if (s.size() == 1) cout << s; else { vector<char> vs; for (int i = 0; i < s.size(); i += 2) vs.push_back(s[i]); sort(vs.begin(), vs.end()); for (int i = 0; i < vs.size() - 1; ++i) cout << vs[i] << "+"; cout << vs[vs.size() - 1]; } } int main() { std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ha(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int length; bool true_false; char S[100], aux, digits[4] = "123"; cin >> S; length = strlen(S); for (int i = 0, x = 0, j; i < length; i += 2) { true_false = false; if (S[i] != digits[x]) { for (j = i + 2; j < length; j += 2) { if (S[i] != digits[x]) { if (S[j] == digits[x]) { aux = S[i]; S[i] = S[j]; S[j] = aux; i += 2; } else { if (j == length - 1) { true_false = true; } } } else { i += 2; } } } if (true_false) { x++; i -= 2; } } for (int i = 0, x = 0, j; i < length; i += 2) { if (S[i] != digits[x]) { x++; if (S[i] != digits[x]) { for (j = i + 2; j < length; j++) { if (S[j] == S[i]) { aux = S[j - 2]; S[j - 2] = S[i]; S[i] = aux; break; } } } } } cout << S << endl; }
#include <bits/stdc++.h> int main() { std::string input; std::cin >> input; std::vector<int> counts(3, 0); for (int i = 0; i < input.size(); ++i) { if (input[i] == '+') { continue; } else { counts[input[i] - '1'] += 1; } } bool first = true; for (int i = 0; i < counts.size(); ++i) { for (int j = 0; j < counts[i]; ++j) { if (!first) { std::cout << "+"; } std::cout << (char('1' + i)); first = false; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { char a[100]; char temp; int i; int j; scanf("%s", a); for (i = 0; (a[i] != '\0') && (a[i + 1] != '\0'); i = i + 2) { for (j = 0; (a[j] != '\0') && (a[j + 1] != '\0'); j = j + 2) { if (a[j] > a[j + 2]) { temp = a[j]; a[j] = a[j + 2]; a[j + 2] = temp; } } } printf("%s\n", a); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { string s1; while (cin >> s1) { string s2 = ""; for (int i = 0; i < s1.size(); i++) { if (s1[i] != '+') s2 += s1[i]; } sort(s2.begin(), s2.end()); for (int i = 0; i < s2.size(); i++) { if (i) cout << '+'; cout << s2[i]; } cout << '\n'; } return 0; }
#include <bits/stdc++.h> int main() { char a[101]; int len, i, temp, j; scanf("%s", &a); len = strlen(a); for (i = 0; i < len; i = i + 2) { for (j = 0; j < len - i - 2; j = j + 2) { if (a[j] > a[j + 2]) { temp = a[j]; a[j] = a[j + 2]; a[j + 2] = temp; } } } printf("%s", a); return 0; }
#include <bits/stdc++.h> using namespace std; int a[105]; int n; int main() { while (cin >> a[n++]) ; sort(a, a + n); cout << a[1]; for (int i = 2; i < n; i++) cout << '+' << a[i]; return 0; }
#include <bits/stdc++.h> using namespace std; bool debug = false; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; long long ln, lk, lm; int main() { string s; cin >> s; vector<int> v; for (int i = 0; i < s.size(); i++) if (s[i] != '+') { v.push_back(s[i] - '0'); } sort(v.begin(), v.end()); for (int(i) = 0; (i) < (int)(v.size()); (i)++) { printf("%d", v[i]); if (i != v.size() - 1) printf("+"); } return 0; }