
#include<stdio.h>
#include<stdlib.h>
char s2[1000];
void expand(char s1[],char s2[])
{
	int i=0,k=0;
	char j;
	for(i=0;s1[i]!='\0';i++)
	{
		if(s1[i]=='-' && i && s1[i+1]!='\0' )
		{
			
			if(s1[i-1]+1<=s1[i+1])
			for(j=s1[i-1]+1;j<=s1[i+1];j++)  /*straight*/
				s2[k++]=j;
			else
			for(j=s1[i-1]-1;j>=s1[i+1];j--)    /*reverse*/
				s2[k++]=j;
			i++;
		}
		else
		s2[k++]=s1[i];
	}
	s2[k]='\0';
}
int main(void) {
    char *s[] = { "a-z-", "z-a-", "-1-6-",
                  "a-ee-a", "a-R-L", "1-9-1",
                  "5-5", NULL };
 
    int i = 0;
    
    while ( s[i] ) {
        
        /*  Expand and print the next string in our array s[]  */
        
        expand(s2, s[i]);
        printf("Unexpanded: %s\n", s[i]);
        printf("Expanded  : %s\n", s2);
        ++i;
    }
    
    return 0;
}
