Skip to content

Instantly share code, notes, and snippets.

@fakruboss
Last active February 15, 2019 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fakruboss/bd46ae0aef53457c63d5e2beadeba9a0 to your computer and use it in GitHub Desktop.
Save fakruboss/bd46ae0aef53457c63d5e2beadeba9a0 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
int main(void) {
int len,i;
char str[100];
gets(str);
len = strlen(str);
if (len < 3) {
printf("%s",str);
}
if (len%2 == 0) {
printf("%c,",str[0]);
for(i=1; i<len-3; i+=2){
printf("%c%c,",str[i],str[i+1]);
}
} else {
for(i=0; i<len-4; i+=2){
printf("%c%c,",str[i],str[i+1]);
}
}
printf("%c%c%c",str[len-3],str[len-2],str[len-1]);
return 0;
}
@fakruboss
Copy link
Author

  1. didn't handle leading zeros

@Arafath08
Copy link

Good @fakruboss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment