Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Praful932
Created April 2, 2019 16:12
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 Praful932/f67551bbbc0d58311e488acdadd4a5bb to your computer and use it in GitHub Desktop.
Save Praful932/f67551bbbc0d58311e488acdadd4a5bb to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int k=0,freq=0,pos=0,c=0;
char no[10000];
char out[20];
scanf("%s",no);
int len=strlen(no);
for(int j=0;j<len;j=j+freq)
{
freq=0;
int first=no[j]-48;
while(1)
{
if((no[k]-48)==first)
freq++;
else
break;
k++;
}
out[pos]=freq;
out[pos+1]=first;
pos=pos+2;
}
printf("%s",out);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment