using Gene logic ,  but we need to take care of number with more than 1
digits , so updated gene's code is as follows :-


#include<stdio.h>
#define MAX 1000

int copy(char *str,int len)
{
int max_len=MAX-1,i;
    for(i=len-1;i>=0;i--)
    {
        str[max_len]=str[i];
        max_len--;
    }
return max_len+1;
}

void runLength(char *str)
{
unsigned int j,k=1,loop=0,res_len=0;
int i,n_start;
char c;
/*copying input to the end of the buffer*/
n_start=copy(str,strlen(str));

    for(i=MAX-1;i>=n_start;i--)
    {
        if(str[i]>='0' && str[i]<='9')
        {
            continue;
        }
        else
        {
            sscanf(&str[i],"%c%d",&c,&loop);
            for(j=0;j<loop;j++)
            {
                str[res_len]=c;
                res_len++;
            }
        }
    }
    str[res_len]='\0';
    printf("\nDecoded Msg = %s\n",str);
}

int main()
{
char str[MAX];
memset(&str,0,MAX);
printf("\nEnter String = ");
scanf("%s",str);
runLength(str);

return 1;
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to