帮忙看这道题,高精度加法
Description 输入两个整数x,y,输出它们的和。
Input
输入两个整数x,y(0 <= x,y <= 10^100)
Output
输出它们的和
Sample Input
123
234
Sample Output
357
#include <stdio.h> int get_integer(char n[]) { char d, i = 1; n[0] = 0; d = getchar(); while (d != '\n') { n[i] = d - '0'; i++; d = getchar(); } n[0] = i - 1; for (; i < 103; i++) { n[i] = 0; } for (i = 1; i <= n[0] / 2; i++) { d = n[i]; n[i] = n[n[0] - i + 1]; n[n[0] - i + 1] = d; } return 0; } int put_integer(char n[]) { int i; for (i = n[0]; i > 0; i--) { printf("%d", n[i]); } printf("\n"); return 0; } int add_integer(char r[], char lop[], char rop[]) { char c = 0, i, j = (lop[0] > rop[0] ? lop[0] : rop[0]); for (i = 1; i <= j; i++) { r[i] = lop[i] + rop[i] + c; c = r[i] / 10; r[i] %= 10; } r[i] = c; r[0] = i + c - 1; return 0; } int main() { char a[103], b[103]; get_integer(a); get_integer(b); add_integer(a, a, b); put_integer(a); return 0; }