CodeForces 339 A.Helpful Maths(水~)

来源:互联网 发布:软件设计师考试准考证 编辑:程序博客网 时间:2024/05/17 06:38

Description

给出一个1,2,3的求和式,要求把被加数排完序后输出该求和式

Input

一个1,2,3的求和式s,串长不超过100

Output

输出有序的求和式

Sample Input

1+1+3+1+3

Sample Output

1+1+1+3+3

Solution

水题,把数字拿出来排个序然后从小到大输出即可

Code

#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<queue>#include<map>#include<set>#include<ctime>using namespace std;typedef long long ll;typedef pair<int,int>P;const int INF=0x3f3f3f3f,maxn=100001;char s[maxn];int res,a[maxn];int main(){    while(~scanf("%s",s))    {        int n=strlen(s);        res=0;        for(int i=0;i<n;i+=2)a[res++]=s[i]-'0';        sort(a,a+res);        for(int i=0;i<res-1;i++)printf("%d+",a[i]);        printf("%d\n",a[res-1]);    }    return 0;}