#197 (div.2) A. Helpful Maths

1.题目描述:点击打开链接

2.解题思路:抽取出所有的数字,排序后输出即可。

3.代码:

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<functional>
using namespace std;

#define me(s) memset(s,0,sizeof(s))
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair <int, int> P;
const int N=100;
char s[N];
int a[N];
int main()
{
    while(~scanf("%s",s))
    {
        me(a);
        int len=strlen(s);
        for(int i=0;i<len;i+=2)
            a[i/2]=s[i]-'0';
        sort(a,a+len/2+1);
        for(int i=0;i<len/2+1;i++)
            printf("%d%c",a[i],"+\n"[i==len/2]);
    }
}

你可能感兴趣的:(排序,codeforces)