View Code of Problem 101

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[100],b[100];
    while(gets(a)!=NULL){
        int k = 0,j = 0;
        int len= strlen(a);
        for(int i = len-1;i >= 0;i--){
            if(a[i] != ','){
                if(k % 3 ==0&& k != 0){
                    b[j++] = ',';
                }
                b[j++] = a[i];
                k++;
            }

        }
        for(int i = j- 1;i >= 0;i--){
                printf("%c",b[i]);
        }
        printf("\n");
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 101