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"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.