View Code of Problem 101

    # include <stdio.h>
    # include <string.h>
     
    int main(void)
    {
    	
    	char str1[100] ;
    	while(scanf("%s",str1) != EOF)
    	{
    		int len , i , j = 0 , count = 0;
    		char str2[100]={0};
    		len = strlen (str1);
    		for(i = len - 1 ; i >= 0 ; i--)
    		{
    			if(str1[i] != ',')
    			{
    				if(count % 3 == 0 && count != 0)
    				{
    					str2[j] = ',';
    					j++;
    				}
    				str2[j] = str1[i];
    				j++;
    				count++;
    			}
    		}
    		for(i = j-1 ; i >= 1 ; i--)
    			printf("%c",str2[i]);
    		printf("%c\n",str2[0]);
    	}
    	
    	return 0;
    }

Double click to view unformatted code.


Back to problem 101