A. Helpful mathstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Xenia The beginner mathematician is a third year student at elementary school. She's now learning the addition operation.
The teacher have written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum is only contains numbers 1, 2 and 3. Still, that's isn ' t enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can ' t calculate sum 1+3+2+1 But she can calculate sums 1+1+2 and 3+3.
You ' ve got the sum of that is written on the board. Rearrange the Summans and print the sum in such a to that Xenia can calculate the sum.
Input
The first line contains a non-empty string s -the sum Xenia needs to count. String s contains no spaces. It is only contains digits and characters "+". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at the most characters long.
Output
Print the new sum that Xenia can count.
Examplesinput
3+2+1
Output
1+2+3
Input
1+1+3+1+3
Output
1+1+1+3+3
Input
2
Output
2
"Code":
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm>using namespace std;const int n=100005;int K;char s[110];int a[110];int Main () { scanf ("%s", s); for (int i=0;i<strlen (s); i+=2)//+=2 { a[k++]=s[i]-' 0 '; } Sort (a,a+k); printf ("%d", a[0]);//First front none +, separate output for (int i=1;i<k;i++) printf ("+%d", A[i]); printf ("\ n");}
Codeforces Round #197 (Div. 2) A. Helpful Maths "string/to a single add-on calculation that contains only the numbers 1, 2, 3, which require reordering, so that the number of added numbers from small to large"