fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int c, bc, count, flag;
  5. bc = 0;
  6. flag = 0;
  7. while ((c = getchar()) != -1 && c != '\n') {
  8. flag = 1;
  9. if(c != bc) {
  10. if (count == 0) putchar(bc);
  11. else printf("%c%d", bc, count + 1);
  12. count = 0;
  13. } else {
  14. count++;
  15. }
  16. bc = c;
  17. }
  18. if (flag) {
  19. if (count == 0) putchar(bc);
  20. else printf("%c%d", bc, count + 1);
  21. } else {
  22. printf("0");
  23. }
  24. putchar('\n');
  25. }
  26. /* end */
  27.  
Runtime error #stdin #stdout 0s 2252KB
stdin
aaaaaaaaaabbbbbbbbbbbbcccccccddddddddddeeeeeeefffffffffghiiiiiiiii
stdout
a10b12c7d10e7f9ghi9