Codeforces Helpful Maths

#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

#define sf scanf
#define pf printf

using namespace std;

char ch[1100];
int ar[1100];

int main()
{
    while(~sf("%s" , &ch))
    {
        int len = strlen(ch) , i , maxi = -1 , tmp , arlen=0 ;

        for(i=0; i<len; i++)
        {
            if(ch[i]>='1' and ch[i]<='4')
            {
                tmp = ch[i] - 48;
                ar[arlen++] = tmp;
            }
        }

        sort(ar, ar+arlen);

        //for(i=0; i<arlen; i++) cout << ar[i] << " ";

        bool f=false;

        for(i=0; i<arlen; i++)
        {
            if(!f)
            {
                pf("%d" , ar[i]);
                f=true;
            }

            else
            {
                pf("+%d" , ar[i]);
            }
        }

        pf("\n");
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number