View Code of Problem 101

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

int main(){
	char s[100];
	while(gets(s)){
		int len = strlen(s);
		int x=len/5;
		int number = len-x;
		int count = 3-number%3;
		for(int i=0;i<len;i++){
			if(s[i]!=','){
				printf("%c",s[i]);
				count++;
				if(count%3==0&&i!=len-1){
					printf(",");
				}
			}
		}
		printf("\n");
	}
}

Double click to view unformatted code.


Back to problem 101