View Code of Problem 101

#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
    char s[100],t[100];

    while(scanf("%s",s) != EOF)
    {
        int i,k = 0,len,count = 0;
        len = strlen(s);
        for(i = len-1;i >= 0;i--)
        {
            if(s[i] != ',')
            {
                t[k++] = s[i];
                count++;
                if(count%3==0&&i)
                    t[k++] = ',';
            }
        }
        for(i = k-1;i >= 0;i--)
            printf("%c",t[i]);
        putchar(10);
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 101