#include<stdio.h> #include <string.h> #include<stdlib.h> char* numContinualAlpha(char* arr) { int prev,c; int num; int i,j,k; num = 0; prev = arr[0]; j = 0; for(i = 0;arr[i] != '/0';i++) { c = arr[i]; if(prev == c) { num++; } else { arr[j] = prev; if(num == 1) { j += 1; } else { k = sprintf(&arr[j+1],"%d",num); j += (k+1); arr[j] = c; } prev = c; num = 1; } } arr[j] = prev; if(num == 1) { j += 1; arr[j] = '/0'; } else if(num > 1) { k = sprintf(&arr[j+1],"%d",num); j += (k+1); } return arr; } int main() { char arr[] = ""; printf("%s/n",numContinualAlpha(arr)); }