关于c语言的一个程序

img


事例如下

img


对代码进行解释

就是遍历字符串,如果找到'-'字符,那么就补充左右两个字符之间的所有字符呗

#include <stdio.h>
int main()
{
    char s[1000];
    int i=0,j;
    gets(s);
    while(s[i] != 0)
    {
        if(s[i] == '-' && i!=0 && s[i+1] != 0)
        {
              for(j=s[i-1]+1;j<s[i+1];j++)
                  printf("%c",j);
        }
        else
              printf("%c",s[i]);
        i++;
    }
    return 0;
}