text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long bpw(long long a, long long b) {
long long ans = 1;
while (b > 0) {
if (b % 2) ans = (ans * a) % M;
a = (a * a) % M;
b >>= 1;
}
return ans;
}
bool isPerfectSquare(int n) {
int x = sqrt(n);
return (x * x == n);
}
void sail() {
string s;
cin >> s;
int n = s.size();
if (n == 1) {
cout << s << '\n';
} else {
vector<int> v;
for (int i = 0; i < n; ++i) {
if (s[i] == '+') {
continue;
} else {
v.push_back(s[i] - '0');
}
}
sort(v.begin(), v.end());
string ans = "";
for (int i = 0; i < v.size(); ++i) {
ans = ans + (char)(v[i] + '0') + "+";
}
cout << ans.substr(0, n) << '\n';
}
}
int main() {
ios_base ::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
while (t--) {
sail();
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long arr[5], cnt;
string s;
int main() {
cin >> s;
for (long long i = 0; i < s.length(); i++) {
if (s[i] == '1') {
arr[1]++;
cnt++;
}
if (s[i] == '2') {
arr[2]++;
cnt++;
}
if (s[i] == '3') {
arr[3]++;
cnt++;
}
}
for (long long i = 0; i < cnt; i++) {
if (arr[1] > 0) {
arr[1]--;
cout << 1;
} else if (arr[2] > 0) {
cout << 2;
arr[2]--;
} else if (arr[3] > 0) {
cout << 3;
arr[3]--;
}
if (i == cnt - 1) {
cout << endl;
} else {
cout << '+';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int one = 0, two = 0, three = 0;
string a;
string s;
cin >> s;
int n = s.length();
for (int i = 0; i < n; i += 2) {
if (s[i] == '1') {
one++;
} else {
if (s[i] == '2') {
two++;
} else {
three++;
}
}
}
for (int i = 0; i < one - 1; i++) {
cout << "1+";
}
if (one > 0) {
if (three == 0 && two == 0) {
cout << '1';
} else {
cout << "1+";
}
}
for (int i = 0; i < two - 1; i++) {
cout << "2+";
}
if (two > 0) {
if (three == 0) {
cout << '2';
} else {
cout << "2+";
}
}
for (int i = 0; i < three - 1; i++) {
cout << "3+";
}
if (three > 0) {
cout << '3';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
int arr[100] = {0};
int count = 0, ibef = 0, jbef = 0, min = 100, counter = 0;
cin >> x;
int z = x.size();
for (int i = 0; i < z; i++) {
if (x[i] != '+' && x[i] != 0) {
arr[count++] = x[i] - 48;
counter++;
}
}
for (int i = 0; i < count; i++) {
min = arr[i];
for (int j = i + 1; j < count; j++) {
if (arr[j] < arr[i]) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
for (int i = 0; i < count; i++) {
if (i == count - 1) {
cout << arr[i];
return 0;
}
cout << arr[i] << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s = "";
cin >> s;
long long int c1 = 0, c2 = 0, c3 = 0;
for (long long int i = 0; i < s.size(); i = i + 2) {
if (s[i] == '1')
c1++;
else if (s[i] == '2')
c2++;
else {
c3++;
}
}
string p = "";
for (long long int i = 0; i < c1; i++) {
p += "1+";
}
if (c2 || c3) {
for (long long int i = 0; i < c2; i++) {
p += "2+";
}
if (c3) {
for (long long int i = 0; i < c3; i++) {
if (i == c3 - 1) {
p += "3";
break;
}
p += "3+";
}
} else {
p = p.substr(0, p.size() - 1);
}
} else {
p = p.substr(0, p.size() - 1);
}
cout << p << '\n';
cerr << "Time : "
<< 1000 * ((long double)clock()) / (long double)CLOCKS_PER_SEC << "ms\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char t[110];
int main() {
int i = 0;
int temp;
while (cin >> t[i]) {
i++;
}
sort(t, t + i);
for (int j = 0; j < i; j++) {
if (j > 0) {
if (t[j - 1] >= '1' && t[j - 1] <= '3') {
cout << "+";
}
}
if (t[j] >= '1' && t[j] <= '3') {
cout << t[j];
}
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using std::sort;
const int SIZE = 100;
int dig[SIZE + 10];
char str[SIZE + 10];
int strsplit(char *str, int len) {
int size = -1;
for (char *p = strtok(str, "+"); p != NULL; p = strtok(NULL, "+"))
sscanf(p, "%d", &dig[++size]);
return size;
}
int main() {
while (scanf("%s", str) != -1) {
int len = strlen(str);
int size = strsplit(str, len);
if (size < 0) {
printf("\n");
continue;
}
sort(dig, dig + size + 1);
for (int i = 0; i < size; i++) printf("%d+", dig[i]);
printf("%d\n", dig[size]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int i, p, count = 0;
int H[3];
memset(H, 0, sizeof(H));
for (i = 0; i < s.size(); i = i + 2) {
if (s[i] == '1') {
H[0] += 1;
} else if (s[i] == '2') {
H[1] += 1;
} else {
H[2] += 1;
}
}
if (s.size() == 1) {
cout << s[0];
} else {
for (i = 0; i < 3; i++) {
p = H[i];
while (p) {
cout << i + 1;
count++;
if (count == s.size()) {
cout << "";
} else {
cout << '+';
}
count++;
p--;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int a = 0, b = 0, c = 0;
char ch;
while (ch = getchar()) {
if (ch == '1')
a++;
else if (ch == '2')
b++;
else if (ch == '3')
c++;
else if (ch == '\n')
break;
}
bool first = true;
for (int i = 0; i < a; i++) {
if (first == true) {
printf("1");
first = false;
} else
printf("+1");
}
for (int i = 0; i < b; i++) {
if (first == true) {
printf("2");
first = false;
} else
printf("+2");
}
for (int i = 0; i < c; i++) {
if (first == true) {
printf("3");
first = false;
} else
printf("+3");
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[101];
int b[51];
int main() {
cin >> a;
int leng = strlen(a);
for (int i = 0; i < leng; i += 2) {
b[i / 2] += a[i] - 48;
}
sort(b, b + leng / 2 + 1);
for (int i = 0; i < leng / 2; ++i) cout << b[i] << "+";
cout << b[leng / 2];
}
|
#include <bits/stdc++.h>
using namespace std;
long long int exp(long long int x, long long int y) {
if (y == 0) return 1;
if (y == 1) return x;
if (y % 2 == 0)
return exp(x, y / 2) * exp(x, y / 2);
else
return x * exp(x, y / 2) * exp(x, y / 2);
}
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
return (a * b) / gcd(a, b);
}
int l;
long long int fact(long long int x) {
if (x == 1)
return 1;
else
return x * fact(x - 1);
}
bool isPrime(int x) {
int ans = 0;
for (int i = 2; i <= sqrt(x); ++i) {
if (x % i == 0) {
ans = 1;
i = x;
}
}
if (ans == 0)
return true;
else
return false;
}
void solve() {
string s;
cin >> s;
vector<int> v;
for (int i = 0; i < s.length(); ++i) {
if (s[i] != '+') v.push_back((int)s[i] - '0');
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
if (i == v.size() - 1)
cout << v[i];
else
cout << v[i] << "+";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int a[105];
string s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
n = 0;
for (char ch : s) {
if (ch != '+') {
n++;
a[n] = ch - '0';
}
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
cout << a[i];
if (i < n) {
cout << '+';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int i, j;
cin >> s;
for (i = 0; i < s.size(); i += 2) {
for (j = 0; j < s.size() - 1; j += 2) {
if (s[j] > s[j + 2]) {
swap(s[j], s[j + 2]);
}
}
}
cout << s;
}
|
#include <bits/stdc++.h>
using namespace std;
bool f(int x, int y) { return x < y; }
int main() {
int n, l, ch, i, t;
string s;
getline(cin, s);
l = s.size();
vector<int> a;
for (i = 0; i < l; i++) {
t = i + 1;
if (t % 2 != 0) {
ch = s[i] - 48;
a.push_back(ch);
}
}
sort(a.begin(), a.end(), f);
vector<int>::iterator it;
it = a.begin();
cout << *it;
for (it = a.begin() + 1; it < a.end(); it++) {
cout << "+" << *it;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char str[105], c[105];
int a[105];
int main() {
scanf("%s", str);
int cnt = 0;
for (int i = 0; i < strlen(str); i++) {
if (str[i] >= '0' && str[i] <= '9') a[cnt++] = str[i] - '0';
}
sort(a, a + cnt);
for (int i = 0; i < cnt - 1; i++) {
printf("%d+", a[i]);
}
printf("%d\n", a[cnt - 1]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
string s;
cin >> s;
int count1 = 0, count2 = 0, count3 = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1') {
count1++;
} else if (s[i] == '2') {
count2++;
} else {
if (s[i] == '3') {
count3++;
}
}
}
string c;
while (count1-- > 0) {
c += "1+";
}
while (count2-- > 0) {
c += "2+";
}
while (count3-- > 0) {
c += "3+";
}
int n = c.size();
cout << c.substr(0, n - 1);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string arr;
int str[100];
int i, j = 0;
cin >> arr;
for (i = 0; i < arr.length(); i++) {
if (arr[i] >= 49 && arr[i] <= 51) str[j++] = arr[i] - 48;
}
sort(str, str + j);
for (i = 0; i < j; i++) {
cout << str[i];
if (i < j - 1) cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char str1[100];
int i, j, n, temp;
scanf("%s", str1);
n = strlen(str1);
for (i = 0; i < n - 2; i = i + 2) {
for (j = i + 2; j < n; j = j + 2) {
if (str1[i] > str1[j]) {
temp = str1[i];
str1[i] = str1[j];
str1[j] = temp;
}
}
}
printf("%s", str1);
return 0;
}
|
#include <bits/stdc++.h>
std::string solve(std::string input) {
int n = input.length();
if (n == 1) return input;
for (int i = 0; i < n - 1; i += 2) {
for (int j = 0; j < n - i - 1; j += 2) {
int current = input.at(j) - '0';
int next = input.at(j + 2) - '0';
if (current > next) {
int temp = input.at(j);
input.at(j) = input.at(j + 2);
input.at(j + 2) = temp;
}
}
}
return input;
}
int main() {
std::string input;
std::getline(std::cin, input);
std::cout << solve(input) << std::endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
string s, s1;
cin >> s;
int count = 0;
sort(s.begin(), s.end());
for (int i = 0; i < s.length(); ++i) {
if (s[i] == '+') count++;
}
std::vector<string> v(s.length());
for (int i = count; i < s.length(); ++i) {
v[i] = s[i];
}
if (count != 0)
for (int i = count; i < v.size() - 1; ++i) {
cout << v[i] << "+";
}
cout << v[v.size() - 1];
}
int main() { solve(); }
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char ch[150];
int i, l, c1 = 0, c2 = 0, c3 = 0;
gets(ch);
l = strlen(ch);
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(int argc, const char* argv[]) {
string sum;
cin >> sum;
int size = sum.length();
vector<char> numbers;
for (int i = 0; i < size; i++) {
if (sum[i] != '+') {
numbers.push_back(sum[i]);
}
}
sort(numbers.begin(), numbers.end());
for (int i = 0; i < numbers.size(); i++) {
if (i != numbers.size() - 1) {
cout << numbers.at(i) << '+';
} else {
cout << numbers.at(i);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string num;
cin >> num;
int a = 0, b = 0, c = 0, s = num.size();
for (int i = 0; i < s; i++) {
if (num[i] == '1')
a++;
else if (num[i] == '2')
b++;
else
c++;
i++;
}
for (int i = 0; i < a; i++) {
if (i != 0) printf("+");
printf("1");
}
if (b != 0 && a != 0) printf("+");
for (int i = 0; i < b; i++) {
if (i != 0) printf("+");
printf("2");
}
if (c != 0 && (b != 0 || a != 0)) printf("+");
for (int i = 0; i < c; i++) {
if (i != 0) printf("+");
printf("3");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
int c = 0, c1 = 0, c2 = 0, c3 = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1') c1++;
if (s[i] == '2') c2++;
if (s[i] == '3') c3++;
if (s[i] == '+') c++;
}
if (c != 0) {
while (c > 0) {
while (c1 > 0) {
cout << "1";
if (c > 0) cout << "+";
c1--;
c--;
}
while (c2 > 0) {
cout << "2";
if (c > 0) cout << "+";
c2--;
c--;
}
while (c3 > 0) {
cout << "3";
if (c > 0) cout << "+";
c3--;
c--;
}
}
} else
cout << s;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char arr[100];
cin >> arr;
int size = strlen(arr);
int count1 = 0, count2 = 0, count3 = 0, l = 0;
for (int i = 0; i < size; i++) {
if (arr[i] == '1') count1++;
if (arr[i] == '2') count2++;
if (arr[i] == '3') count3++;
}
for (int d = 0; d < count1; d++) {
if (l == size - 1)
cout << "1";
else
cout << "1+";
l += 2;
}
for (int s = 0; s < count2; s++) {
if (l == size - 1)
cout << "2";
else
cout << "2+";
l += 2;
}
for (int a = 0; a < count3; a++) {
if (l == size - 1)
cout << "3";
else
cout << "3+";
l += 2;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[1001];
string s;
cin >> s;
int count = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '+') {
continue;
} else {
arr[count++] = s[i] - '0';
}
}
sort(arr, arr + count);
for (int i = 0; i < count; i++) {
cout << arr[i];
if (i == count - 1) {
break;
}
cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool logic(char x, char y) { return x > y; }
int main() {
char s[100];
cin >> s;
vector<char> v;
stack<char> st;
int i = 0;
while (s[i] != '\0') {
if (s[i] == '+') {
st.push(s[i]);
} else if (s[i] >= 48 && s[i] <= 58) {
v.push_back(s[i]);
}
i++;
}
sort(v.begin(), v.end(), logic);
while (v.empty() == false) {
cout << *(v.end() - 1);
v.pop_back();
if (v.size() > 0) {
cout << "+";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j;
string s;
char c;
getline(cin, s);
for (i = 0; i < s.length(); i++)
for (j = i + 1; j < s.length(); j++)
if (isdigit(s[i]) && isdigit(s[j]) && s[i] >= s[j]) {
c = s[i];
s[i] = s[j];
s[j] = c;
}
cout << s;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int a = 0, b = 0, c = 0;
char ch;
while (ch = getchar()) {
if (ch == '1')
a++;
else if (ch == '2')
b++;
else if (ch == '3')
c++;
else if (ch == '\n')
break;
}
bool first = true;
for (int i = 0; i < a; i++) {
if (first == true) {
printf("1");
first = false;
} else
printf("+1");
}
for (int i = 0; i < b; i++) {
if (first == true) {
printf("2");
first = false;
} else
printf("+2");
}
for (int i = 0; i < c; i++) {
if (first == true) {
printf("3");
first = false;
} else
printf("+3");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int len = s.length();
sort(s.begin(), s.end());
for (int i = 0; i < len - 1; i++) {
if (s[i] == '+') continue;
cout << s[i] << "+";
}
cout << s[len - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j;
string b;
cin >> b;
j = b.size();
sort(b.begin(), b.end());
i = (b.size() - 1) / 2;
b = b.substr(i, j);
for (int x = 0, j = 0; j < ((2 * i) + 1); j++) {
if (j % 2 == 0) {
cout << b[x];
x++;
} else
cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
char temp;
cin >> s;
for (int x = 0; x < s.length(); x += 2) {
for (int y = 0; y < s.length(); y += 2) {
if (s[x] < s[y]) {
temp = s[x];
s[x] = s[y];
s[y] = temp;
}
}
}
cout << s;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
cin >> x;
vector<int> v;
for (auto i : x) {
if (i - '0' >= 0 && i - '0' <= 9) {
v.push_back(i - '0');
}
}
sort(v.begin(), v.end());
for (register int i = 0; i < (int)v.size() - 1; i++) printf("%d+", v[i]);
printf("%d\n", v[v.size() - 1]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
string s;
cin >> s;
long long one = 0, two = 0, three = 0, n = s.length();
for (long long i = 0; i < n; i++) {
if (s[i] == '1')
one++;
else if (s[i] == '2')
two++;
else if (s[i] == '3')
three++;
}
for (long long i = 0; i < one; i++) {
cout << 1;
if (i != one - 1 || two != 0 || three != 0) cout << "+";
}
for (long long i = 0; i < two; i++) {
cout << 2;
if (i != two - 1 || three != 0) cout << "+";
}
for (long long i = 0; i < three; i++) {
cout << 3;
if (i != three - 1) cout << "+";
}
}
void champ() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
signed main() {
champ();
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, cnt = 0, ans = 0, rem = 0;
string s, s1, s2, s3, s4;
deque<char> d, d1, d2;
vector<long long> v, v1, v2, v3;
int main() {
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i % 2 == 0) {
d.push_back(s[i]);
}
}
sort(d.begin(), d.end());
for (int i = 0; i < d.size(); i++) {
if (i != d.size() - 1) {
cout << d[i] << "+";
} else {
cout << d[i];
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[10] = {0};
string number;
int x = 0;
cin >> number;
for (int i = 0; i < number.length(); i++) {
if (number[i] != '+') arr[(int)number[i] - 49]++;
}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < arr[i]; j++) {
if (x == 0)
cout << i + 1;
else
cout << "+" << i + 1;
x++;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
void fast() {
std::ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const long long MOD = 1e9 + 7;
int main() {
long long t = 1;
while (t--) {
string s;
cin >> s;
vector<long long> vc;
long long siz = s.size();
for (long long i = 0; i < siz; ++i) {
if (s[i] >= '0' && s[i] <= '9') {
vc.push_back(int(s[i] - 48));
}
}
sort((vc).begin(), (vc).end());
long long second = vc.size();
for (long long i = 0; i < second; ++i) {
if (i != second - 1)
cout << vc[i] << '+';
else
cout << vc[i];
}
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
char x[1000005];
int main() {
int i, len, c1, c2, c3;
c1 = c2 = c3 = 0;
scanf("%s", &x);
len = strlen(x);
for (i = 0; i < len; i++) {
if (x[i] == '1') c1++;
if (x[i] == '2') c2++;
if (x[i] == '3') c3++;
}
for (i = 0; i < c1; i++) {
printf("1");
if (c1 + c2 + c3 - 1 > i) printf("+");
}
for (i = 0; i < c2; i++) {
printf("2");
if (c1 + c2 + c3 - 1 > i + c1) printf("+");
}
for (i = 0; i < c3; i++) {
printf("3");
if (c1 + c2 + c3 - 1 > i + c1 + c2) printf("+");
}
puts("");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MN = 10e5 + 10;
int x[MN];
int main() {
string s;
cin >> s;
int j = 0;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '1') {
x[j] = 1;
j++;
} else if (s[i] == '2') {
x[j] = 2;
j++;
} else if (s[i] == '3') {
x[j] = 3;
j++;
}
}
sort(x, x + j);
for (int i = 0; i < j; i++)
if (j - 1 == i) {
cout << x[i];
return 0;
} else
cout << x[i] << "+";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string a;
cin >> a;
int l = a.length();
int p = (l - 1) / 2;
int n = p + 1;
sort(a.begin(), a.end());
a.erase(0, p);
for (int i = n - 1; i > 0; i = i - 1) {
a.insert(i, "+");
}
cout << a << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
const bool is_impar(T x) {
return (bool)(x & 1);
}
int n;
string s, rez;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> s;
for (int i = 0; i < ((int)(s).size()); i += (2)) rez += s[i];
sort(rez.begin(), rez.end());
cout << rez[0];
for (int i = 1; i < (int)(rez).size(); i++) cout << '+' << rez[i];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int a[101], j = 0;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (s[i] == '+') {
continue;
} else {
a[j++] = s[i] - '0';
}
}
sort(a, a + j);
for (int k = 0; k <= j - 1; k++) {
cout << a[k];
if (k < j - 1) {
cout << "+";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string ss;
vector<int> s;
cin >> ss;
for (int i = 0; i < ss.size(); i += 2) {
s.push_back(ss[i] - '0');
}
sort(s.begin(), s.end());
for (int i = 0; i < s.size() - 1; i++) {
cout << s[i] << "+";
}
cout << s[s.size() - 1] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int f[3] = {};
for (long long i = 0; i < s.size(); i++) {
if (s[i] != '+') {
f[s[i] - '1']++;
}
}
int k = 1, t = f[0] + f[1] + f[2];
for (int i = 0; i < t; i++) {
while (!f[k - 1]) k++;
if (i < t - 1)
cout << k << '+';
else
cout << k;
f[k - 1]--;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
int x, y, w = -1;
int main() {
cin >> s;
x = s.size();
int n = (x + 1) / 2;
int arr[n];
for (int i = 0; i < x; i++) {
if (s[i] != '+') {
w++;
y = s[i] - '0';
arr[w] = y;
}
}
sort(arr, arr + n);
for (int i = 0; i < n; i++) {
cout << arr[i];
if (i != n - 1) {
cout << '+';
}
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char string[101];
int arr[100];
int map = 0;
int temp;
scanf("%s", &string);
int length = strlen(string);
for (int i = 0; i < length; i++) {
if (string[i] == '1') {
arr[map] = 1;
map++;
} else if (string[i] == '2') {
arr[map] = 2;
map++;
} else if (string[i] == '3') {
arr[map] = 3;
map++;
}
}
for (int i = 0; i < map - 1; i++) {
for (int j = 0; j < map - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
for (int i = 0; i < map; i++) {
if (i == map - 1) {
printf("%d", arr[i]);
} else {
printf("%d+", arr[i]);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char a[10000] = {0};
long b[10000] = {0};
long t = 0, l;
gets(a);
l = strlen(a);
for (int i = 0; i < l; i++) {
if (isdigit(a[i])) {
b[t] = a[i] - 48;
t++;
}
}
sort(b, b + t);
cout << b[0];
for (int j = 1; j < t; j++) {
cout << "+" << b[j];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cnt[105], num[105];
int main() {
int i;
char s[105], a[105];
cin >> s;
int ln = strlen(s);
for (i = 0; i < ln; i += 2) {
int nm = s[i] - '0';
num[nm]++;
}
int flg = 0;
for (int i = 1; i <= num[1]; i++) {
if (flg == 1) {
cout << "+";
}
flg = 1;
cout << 1;
}
for (int i = 1; i <= num[2]; i++) {
if (flg == 1) {
cout << "+";
}
flg = 1;
cout << 2;
}
for (int i = 1; i <= num[3]; i++) {
if (flg == 1) {
cout << "+";
}
flg = 1;
cout << 3;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string arr;
int arr1[101];
int i, j = 0, k, l, n;
cin >> arr;
l = arr.size();
for (i = 0; i < l; i++) {
arr1[j] = (arr[i] - '0');
j++;
i = i + 1;
}
sort(arr1, arr1 + j);
for (k = 0; k <= j - 1; k++) {
if (k == j - 1)
cout << arr1[k] << endl;
else
cout << arr1[k] << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string sum;
cin >> sum;
vector<char> sym;
for (int i = 0; i < sum.length(); ++i) {
if (sum[i] != '+') sym.push_back(sum[i]);
}
sort(sym.begin(), sym.end());
for (int i = 0; i < sym.size(); ++i) {
if (i == 0) {
cout << sym[i];
} else {
cout << "+" << sym[i];
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s1;
cin >> s1;
int n = s1.length();
vector<char> v1;
for (int i = 0; i < n; i++) {
if (s1[i] != '+') {
v1.push_back(s1[i]);
}
}
sort(v1.begin(), v1.end());
int m = v1.size();
for (int i = 0; i < m - 1; i++) {
cout << v1[i] << "+";
}
cout << v1[m - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool compare(int a, int b) { return a < b; }
int main() {
int n, i, j, t;
int sum1 = 0;
int sum2 = 0;
char c[1000];
char z[1000];
char k[1000];
cin >> c;
if (c[1] == '\0')
cout << c[0] << endl;
else {
for (n = 0; c[n] != '\0'; n++)
if (c[n] == '+') {
k[sum1] = '+';
sum1++;
} else {
z[sum2] = c[n];
sum2++;
}
sort(z, z + sum2, compare);
for (i = 0; i < sum1; i++) {
printf("%c", z[i]);
printf("%c", k[i]);
}
printf("%c\n", z[sum2 - 1]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int num1 = 0;
int num2 = 0;
int num3 = 0;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (s[i] == '1') {
num1++;
} else if (s[i] == '2') {
num2++;
} else if (s[i] == '3') {
num3++;
}
}
for (int j = 0; j < num1; j++) {
if (j == 0) {
cout << "1";
} else {
cout << "+1";
}
}
for (int k = 0; k < num2; k++) {
if (k == 0 && num1 == 0) {
cout << "2";
} else {
cout << "+2";
}
}
for (int l = 0; l < num3; l++) {
if (l == 0 && num1 == 0 && num2 == 0) {
cout << "3";
} else {
cout << "+3";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int e = s.size();
sort(s.begin(), s.end());
for (int i = (s.size() / 2); i < s.size() - 1; i++) {
cout << s[i] << "+";
}
cout << s[s.size() - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
int l = s.size();
vector<char> v;
for (int i = 0; i < l; ++i) {
if (s[i] != '+') {
v.push_back(s[i]);
}
}
sort(v.begin(), v.end());
for (int i = 0; i < l; ++i) {
if (i % 2 == 0) {
cout << v[0];
v.erase(v.begin());
} else
cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string a, b;
cin >> a;
for (auto i : a)
if (isdigit(i)) b += i;
sort(b.begin(), b.end());
for (int i = 0; i < b.size(); i++) {
if (i != 0) cout << "+";
cout << b[i];
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
int size;
vector<char> vec;
for (int i = 0; i < str.size(); i += 2) {
vec.push_back(str[i]);
}
sort(vec.begin(), vec.end());
size = vec.size();
for (int i = 0; i < size - 1; i++) cout << vec[i] << "+";
cout << vec.back();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
s.erase(std::remove(s.begin(), s.end(), '+'), s.end());
sort(s.begin(), s.end());
cout << s[0];
for (int i = 1; i < s.size(); i++) cout << '+' << s[i];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s, s1;
cin >> s;
for (int i = 0; i < s.length(); i = i + 2) {
s1 = s1 + s[i];
}
for (int i = 0; i < s1.length() - 1; i++) {
for (int j = 0; j < s1.length() - i - 1; j++) {
if (s1[j] > s1[j + 1]) {
char temp = s1[j];
s1[j] = s1[j + 1];
s1[j + 1] = temp;
}
}
}
for (int i = 0; i < s1.length(); i++) {
if (i != s1.length() - 1) {
cout << s1[i] << "+";
} else {
cout << s1[i];
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
cin >> str;
vector<int> ans;
for (int i = 0; i < str.length() / 2 + 1; i++) {
ans.push_back(str[2 * i] - 48);
}
sort(ans.begin(), ans.end());
for (int i = 0; i < ans.size(); i++) {
cout << ans[i];
if (i + 1 != ans.size())
cout << "+";
else
cout << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, len;
char s[105];
cin >> s;
len = strlen(s);
for (i = 0; i < len; i++) {
for (j = 0; j < len - 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(int argc, char *argv[]) {
int one = 0, two = 0, three = 0;
vector<char> output;
string input;
cin >> input;
for (int i = 0; i < input.size(); i++) {
if (input[i] == '1') {
one++;
}
if (input[i] == '2') {
two++;
}
if (input[i] == '3') {
three++;
}
}
for (int i = 0; i < one; i++) {
output.push_back('1');
}
for (int i = 0; i < two; i++) {
output.push_back('2');
}
for (int i = 0; i < three; i++) {
output.push_back('3');
}
for (int i = 0; i < output.size(); i++) {
cout << output[i];
if (i == output.size() - 1) {
return 0;
}
cout << '+';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long a = 0, b = 0, c = 0, n, i, j, k, l, m;
string p;
cin >> p;
l = p.size();
for (i = 0; i < l; i++) {
if (p[i] == '1') a = a + 1;
if (p[i] == '2') b = b + 1;
if (p[i] == '3') c = c + 1;
}
if (a + b == 0 && c > 0) {
cout << 3;
c--;
}
if (a == 0 && b > 0) {
cout << 2;
b--;
}
if (a > 0) {
cout << 1;
a = a - 1;
}
for (i = 1; i <= a; i++) {
cout << "+1";
}
for (i = 1; i <= b; i++) {
cout << "+2";
}
for (i = 1; i <= c; i++) {
cout << "+3";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char row[100];
cin >> row;
int length = 0;
for (int i = 0; row[i] != '\0'; i++) {
length++;
}
for (int i = 0; i < length; i += 2) {
int minindex = i;
for (int j = i + 2; j < length; j += 2)
if (row[j] < row[minindex]) minindex = j;
if (minindex != i) {
char temp = row[minindex];
row[minindex] = row[i];
row[i] = temp;
}
}
cout << row;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<char> a;
for (int i = 0; i < s.size(); ++i) {
if (s[i] != '+') {
a.push_back(s[i]);
}
}
sort(a.begin(), a.end());
for (int i = 0; i < a.size(); ++i) {
if (i != a.size() - 1) {
cout << a[i] << '+';
} else {
cout << a[i];
}
}
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 80112002;
char s[110];
int a[110];
int main() {
scanf("%s", s);
int len = strlen(s);
int cnt = 0;
for (int i = 0; i < len; i++) {
if (s[i] >= '0' && s[i] <= '9') a[++cnt] = s[i] - '0';
}
sort(a + 1, a + 1 + cnt);
for (int i = 1; i <= cnt; i++) {
printf("%d", a[i]);
if (i != cnt)
printf("+");
else
printf("\n");
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char a[100];
gets(a);
int i, x, j = 0, p = 0, d, swap;
x = strlen(a);
int b[100];
for (i = 0; i < x; i++) {
if (a[i] >= 48 && a[i] <= 57) {
b[j] = a[i];
j++;
p++;
}
}
for (j = 1; j < p; j++) {
d = j;
while (d > 0 && b[d] < b[d - 1]) {
swap = b[d];
b[d] = b[d - 1];
b[d - 1] = swap;
d--;
}
}
for (j = 0; j < p; j++) {
printf("%c", b[j]);
if (j < p - 1) printf("+");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<char> v1;
string st;
getline(cin, st);
int s = st.size();
for (int i = 0; i < s; i = i + 2) v1.push_back(st.at(i));
sort(v1.begin(), v1.begin() + v1.size());
for (int i = 0; i < v1.size() - 1; i++) cout << v1.at(i) << '+';
cout << v1.back();
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
long long i, j, c;
int main() {
cin >> s;
for (i = 0; i < s.size(); i = i + 2)
for (j = i + 2; j < s.size(); j = j + 2)
if (s[i] > s[j]) swap(s[i], s[j]);
cout << s << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string sum;
for (int i = 0; i < s.length(); i++) {
if (isdigit(s[i])) {
sum = sum + s[i];
}
}
sort(sum.begin(), sum.end());
for (int i = 0; i < sum.length(); i++) {
cout << sum[i];
if (i != sum.length() - 1) cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> v;
for (int i = 0; i < s.length(); ++i) {
if (s[i] != '+') {
v.push_back(s[i] - 48);
}
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
if (i == v.size() - 1)
cout << v[i];
else
cout << v[i] << "+";
}
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
vector<char> v;
int main() {
cin >> s;
for (int i = (int)(0); i < (int)(s.size()); i++) {
if (s[i] >= '0' && s[i] <= '9') {
v.push_back(s[i]);
}
}
sort(v.begin(), v.end());
for (int i = (int)(0); i < (int)(v.size() - 1); i++) {
cout << v[i] << "+";
}
cout << v[v.size() - 1];
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int temp;
string s;
cin >> s;
for (int i = 0; i < s.length(); i = i + 2) {
for (int j = i + 2; j < s.length(); j = j + 2) {
if (s[i] > s[j]) {
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
}
cout << s;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int a, b, c, i = 0, j = 0, k = 0, n, l;
char s[100];
scanf("%s", &s);
l = strlen(s);
for (n = 0; n < l; n++) {
if (s[n] == '1')
i++;
else if (s[n] == '2')
j++;
else if (s[n] == '3')
k++;
}
l = l / 2 + 1;
n = 0;
for (a = 0; a < i; a++) {
n++;
if (n != l)
printf("1+");
else
printf("1");
}
for (b = 0; b < j; b++) {
n++;
if (n != l)
printf("2+");
else
printf("2");
}
for (c = 0; c < k; c++) {
n++;
if (n != l)
printf("3+");
else
printf("3");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string x;
cin >> x;
if (x.size() <= 2) {
cout << x;
} else {
for (int i = 0; i < x.size(); i += 2) {
for (int j = 0; j <= x.size() - 2; j += 2) {
if (x[j] > x[j + 2]) {
swap(x[j], x[j + 2]);
}
}
}
for (int i = 0; i < x.size(); i++) {
cout << x[i];
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<char> v;
for (int i = 0; i < s.length(); i += 2) {
v.push_back(s[i]);
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++) {
if (i < v.size() - 1) {
cout << v.at(i) << "+";
} else
cout << v.at(i);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string a;
cin >> a;
vector<int> v;
for (int i = 0; i < a.length(); i++) {
switch (a[i]) {
case '1':
v.push_back(1);
break;
case '2':
v.push_back(2);
break;
case '3':
v.push_back(3);
break;
}
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size() - 1; i++) cout << v[i] << "+";
cout << v.back() << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string a, b, c;
cin >> a;
for (size_t i = 0; i < a.length(); i++)
if (a[i] != '+') {
b += a[i];
}
sort(b.begin(), b.end());
for (size_t i = 0; i < b.length(); i++) {
c = c + b[i];
if (c.length() < a.length()) c += '+';
}
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char s[100];
cin >> s;
int i = 0, ind;
while (s[i]) i++;
for (int k = 0; k <= i; k += 2) {
ind = k;
for (int j = k + 2; j <= i; j += 2) {
if (s[j] < s[ind]) {
ind = j;
}
}
swap(s[k], s[ind]);
}
cout << s << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int c1 = 0, c2 = 0, c3 = 0, i, flag = 0;
cin >> s;
for (i = 0; i < s.size(); i++) {
if (s[i] == '1')
c1++;
else if (s[i] == '2')
c2++;
else if (s[i] == '3')
c3++;
}
while (c1--) {
if (flag == 0) {
cout << 1;
flag = 1;
} else
cout << "+" << 1;
}
while (c2--) {
if (flag == 0) {
cout << 2;
flag = 1;
} else
cout << "+" << 2;
}
while (c3--) {
if (flag == 0) {
cout << 3;
flag = 1;
} else
cout << "+" << 3;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string arr;
cin >> arr;
int len = arr.length();
int i = 0;
int j;
j = (len + 1) / 2;
int a[j];
int k;
k = 0;
while (i <= len) {
a[k] = arr.at(i);
k++;
i = i + 2;
}
sort(a, a + j);
i = 0;
k = 0;
while (i <= len) {
arr.at(i) = a[k];
k++;
i = i + 2;
}
cout << arr;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int arr[3] = {0, 0, 0};
string s;
cin >> s;
if (s.size() == 1) {
cout << s << '\n';
} else if (s.size() == 3) {
if (s[0] > s[2])
cout << s[2] << '+' << s[0] << '\n';
else
cout << s << '\n';
} else {
int size = 0;
for (int i = 0; i < s.size(); i = i + 2) {
arr[s[i] - '0' - 1]++;
size++;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < arr[i]; j++) {
--size;
if (size <= 1 && i == 2 && j == arr[i] - 1) {
cout << i + 1;
} else {
cout << i + 1 << '+';
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
string s1, s2, s3;
cin >> s;
int a[3] = {0};
for (int i = 0; i < s.length(); i += 2) {
a[s[i] - 49]++;
}
int temp = a[0] - 1;
if (a[1] != 0 || a[2] != 0) temp = a[0];
for (int i = 0; i < temp; i++) cout << "1+";
if (temp == a[0] - 1 && a[0] != 0) cout << "1";
if (a[2] != 0)
temp = a[1];
else
temp = a[1] - 1;
for (int i = 0; i < temp; i++) cout << "2+";
if (temp == a[1] - 1 && a[1] != 0) cout << "2";
for (int i = 0; i < a[2] - 1; i++) cout << "3+";
if (a[2] != 0) cout << "3";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s, k = "";
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i % 2 == 0) k += s[i];
}
sort(k.begin(), k.end());
for (int i = 0; i < k.size(); i++) {
cout << k[i];
if (i != k.size() - 1) cout << "+";
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
std::string str, str1;
std::cin >> str;
std::vector<int> st;
for (auto& elem : str) {
if (std::isdigit(elem)) {
st.push_back(elem);
}
}
std::sort(st.begin(), st.end());
for (auto& elem : st) {
str1.push_back(elem);
str1.push_back('+');
}
str1.erase(str1.length() - 1, 1);
std::cout << str1 << std::endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> a;
int main() {
cin >> s;
for (int i = 0; i < s.size(); i += 2) a.push_back(s[i] - '0');
sort(a.begin(), a.end());
for (int i = (0); i < (a.size()); ++i) {
if (i) printf("+");
printf("%d", a[i]);
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int i, j;
for (int i = 0; i < s.size(); i += 2) {
for (int j = 0; j < s.size() - 1; j += 2) {
if (s[j] > s[j + 2]) {
swap(s[j], s[j + 2]);
}
}
}
cout << s << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int st = 0;
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'];
}
}
for (int i = 1; i <= 3; i++) {
for (int j = 0; j < cnt[i]; j++) {
if (st) {
cout << "+";
} else {
st = 1;
}
cout << i;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, k;
char s[200];
cin >> s;
int A[4];
for (i = 0; i < 4; i++) A[i] = 0;
k = 0;
for (i = 0; s[i] != '\0'; i++) {
if (s[i] == '+') {
A[k]++;
k = 0;
} else
k = s[i] - '0';
}
A[k]++;
j = 0;
for (i = 1; i <= 3; i++) {
while (A[i] > 0) {
s[j++] = i + '0';
s[j++] = '+';
A[i]--;
}
}
s[j - 1] = '\0';
cout << s;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char s[1000];
int i, j = 0, k, l, a[1000], m, n, t;
cin >> s;
l = strlen(s);
for (i = 0; i < l; i++) {
if ((i % 2) == 0) {
a[j] = (int)s[i];
j++;
}
}
for (m = 1; m < j; m++) {
for (n = 0; n < (j - m); n++) {
if (a[n] > a[n + 1]) {
t = a[n];
a[n] = a[n + 1];
a[n + 1] = t;
}
}
}
for (k = 0; k < j; k++) {
if (k == (j - 1)) {
cout << (char)a[k];
} else {
cout << (char)a[k] << '+';
}
}
cout << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> v;
for (int i = (0); i < (s.size()); ++i) {
v.push_back(s[i] - '0');
++i;
}
sort(v.begin(), v.end());
for (int i = (0); i < (v.size()); ++i) {
if (i) printf("+");
printf("%d", v[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char s[1000];
int i, j = 0, k, l, ln, arr[1000], m, n, temp;
scanf("%s", s);
ln = strlen(s);
for (i = 0; i < ln; i++) {
if ((i % 2) == 0) {
arr[j] = (int)s[i];
j++;
}
}
for (m = 1; m < j; m++) {
for (n = 0; n < (j - m); n++) {
if (arr[n] > arr[n + 1]) {
temp = arr[n];
arr[n] = arr[n + 1];
arr[n + 1] = temp;
}
}
}
for (k = 0; k < j; k++) {
if (k == (j - 1)) {
printf("%c", (char)arr[k]);
} else {
printf("%c%c", (char)arr[k], '+');
}
}
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
string s;
char a[101];
int main() {
cin >> s;
for (int i = 0; i < s.size(); i++)
if (i % 2 == 0) a[i / 2] = s[i];
sort(a, a + s.size() / 2 + 1);
cout << a[0];
for (int i = 1; i <= s.size() / 2; i++) cout << "+" << a[i];
cout << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
int i, n;
string x, y[10] = {"+"};
cin >> x;
sort(x.begin(), x.end());
n = x.length() / 2;
for (i = n; i < x.size(); i++) {
if (i < x.length() - 1)
cout << x[i] << "+";
else
cout << x[i];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int m = 0, p = 0, i, u = 0, l = 0, z, k, n = 0;
string x;
cin >> x;
k = x.size();
if (x[k - 1]) m = 1;
for (i = 0; i < k; i += 2) {
if (x[i] % 3 == 0) {
l = 1;
n = i;
}
if (x[i] % 3 == 2) {
p = 1;
u = i;
}
}
for (i = 0; i < k; i += 2) {
if (x[i] % 3 == 1 && i != k - 1)
cout << x[i] << '+';
else if (x[i] % 3 == 1 && i == k - 1 && (p == 1 || l == 1))
cout << x[i] << '+';
else if (x[i] % 3 == 1 && i == k - 1 && (p == 0 || l == 0))
cout << x[i];
}
for (i = 0; i < k; i += 2) {
if (x[i] % 3 == 2 && i != u) cout << x[i] << '+';
if (x[i] % 3 == 2 && i == u && l == 0) cout << x[i];
if (x[i] % 3 == 2 && i == u && l == 1) cout << x[i] << '+';
}
for (i = 0; i < k; i += 2) {
if (x[i] % 3 == 0 && i != n) cout << x[i] << '+';
if (x[i] % 3 == 0 && i == n) cout << x[i];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
string t;
for (int i = 0; i < s.length(); i++) {
if (s[i] != '+') t.push_back(s[i]);
}
sort(t.begin(), t.end());
{
cout << t[0];
for (int i = 1; i < t.length(); i++) cout << "+" << t[i];
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
char a[105];
char b[105];
int main() {
cin >> a;
int lens = strlen(a);
int count = 0, t = 0;
for (int i = 0; i < lens; i++) {
if (a[i] != '+') {
b[count++] = a[i];
}
}
sort(b, b + count);
for (int i = 0; i < count - 1; i++) {
cout << b[i] << '+';
}
cout << b[count - 1] << endl;
return 0;
}
|
#include <bits/stdc++.h>
int main() {
char s[100], s1[50];
scanf("%s", &s);
int a = strlen(s), m = 0;
for (int i = 0; i < a; i++) {
if (i % 2 == 0) {
s1[m] = s[i];
m++;
}
}
for (int i = 0; i < m; ++i) {
for (int j = i + 1; j < m; ++j) {
if (s1[i] > s1[j]) {
a = s1[i];
s1[i] = s1[j];
s1[j] = a;
}
}
}
for (int i = 0; i < m; i++) {
if (i != (m - 1)) {
printf("%c+", s1[i]);
} else
printf("%c", s1[i]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string str;
getline(cin, str);
int len = str.length();
for (int i = 0; i < len; i += 2) {
for (int j = i + 2; j < len; j += 2) {
if (str.at(i) > str.at(j)) {
swap(str.at(i), str.at(j));
}
}
}
for (int i = 0; i < str.length(); i++) {
cout << str.at(i);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string input, ans;
vector<int> arr;
stringstream ss;
while (cin >> input) {
for (int i = 0; input[i] != '\0'; i++) {
if (input[i] != '+') {
arr.push_back(input[i] - '0');
}
}
sort(arr.begin(), arr.end());
for (auto j = arr.begin(); j < arr.end(); j++) {
if (j != arr.end() - 1) {
ss << *j << '+';
} else {
ss << *j;
}
}
ans = ss.str();
cout << ans;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.