码迷,mamicode.com
首页 > 其他好文 > 详细

codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

时间:2016-07-20 22:59:07      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://www.codeforces.com/problemset/problem/339/A
题意:重新组合加法字符串,使得按照1,2,3的顺序进行排列。
C++代码:

技术分享
#include <iostream>
#include <string>
using namespace std;
int cnt[3];
string s, ans = "";
int main()
{
    cin >> s;
    int len = s.length();
    for (int i = 0; i < len; i += 2)
        cnt[ s[i] - 1 ] ++;
    for (int i = 0; i < 3; i ++)
    {
        while (cnt[i] --)
        {
            char c = 1 + i;
            ans += "+";
            ans += c;
        }
    }
    cout << ans.substr(1);
    return 0;
}
C++

 

codeforces水题100道 第二十五题 Codeforces Round #197 A. Helpful Maths (Div. 2) (strings)

标签:

原文地址:http://www.cnblogs.com/moonlightpoet/p/5689782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!