leetcode-415-文字列加算-C言語

707 ワード

#define LEN 5104
inline int get_len(char *s){
    int i=0;
    while(*s++ != 0)
        i++;
    return i;
}

inline void swap(char *s1, char *s2){
    char c = *s1;
    *s1 = *s2;
    *s2 = c;
}

char *reverse(char *s){
    int i=0, j=get_len(s)-1;
    while(i= 10){
            flag = 1;
            tmp -= 10;
        }
        
        ret[index++] = tmp + '0';
        i++;
        j++;
    }
    
    ret[index++] = 0;
    
    reverse(ret);

    return ret;
}