Sunday, August 17, 2014

uva : 444 - Encoder and Decoder


#include<stdio.h>
#include<string.h>
int main()
{
    char a[5000];
    int y=0;
    while(gets(a)!=NULL)
    {
        int i,j=0,k,l,m,n,num1[5000],lnum1=0;
        if(a[0]>='0'&&a[0]<='9')
        {
            i=strlen(a)-1;
            while(i>=0)
            {
                n=0;
                while(n<32)
                {
                    n=n*10+(a[i]-'0');
                    i--;
                }
                printf("%c",n);
            }
        }
        else
        {
            for(j=strlen(a)-1;j>=0;j--)
            {
                m=a[j];
                lnum1=0;
                while(m!=0)
                {
                    num1[lnum1++]=m%10;
                    m=m/10;
                }
                for(i=0;i<lnum1;i++)
                {
                    printf("%d",num1[i]);
                }
            }
        }
        y=1;

No comments:

Post a Comment