还是扩写,我只能说:指针真好用,以前的六十多行,现在才二十多行

#include <stdio.h>
#include <assert.h>
const int N = 10001;

void expand(char [], char []);

int main()
{
//    freopen("0.in", "r", stdin);
//    freopen("0.out", "w", stdout);

    char s1[N], s2[N * 30];

    while(scanf("%s", s1) != EOF) {
        expand(s1, s2);
        printf("%s\n", s2);
    }

    return 0;
}
void expand(char t[], char s[]){
    char *ps = s;
    char *pt = t;
    for(; *pt != '\0'; ++pt){
        if((*pt-'-'))
            *ps++ = *pt;
        else if(!(*pt - '-') && ps == s)
            ;
        else if(!(*pt - '-') && *(pt - 1) == *(pt + 1))
            pt++;
        else if(!(*pt - '-') && *(pt - 1) < *(pt + 1)){
            int i = 1;
            int x;
            for(x = (*(pt + 1) - *(pt - 1)); i < x; i++)
                *ps++ = *(pt-1)+i;
        }        
    }
    *ps = '\0';
}

上一篇:pt-table-checksum


下一篇:Linux关机和重启命令总结