题解 | #A+B#
A+B
https://www.nowcoder.com/practice/b183eac8dfba4de99d47c1ca4ce9571f
#include <stdio.h> #include <string.h> int main() { char a[15]; char b[15]; while (scanf("%s %s", &a, &b) != EOF) { // 注意 while 处理多个 case // printf("%s:%d ",a,strlen(&a)); int i, j; long long A = 0; for (i = strlen(&a) - 1, j = 1; i >= 0; i--) { if (a[i] == ',' || a[i] == '-') { continue; } A += (a[i] - '0') * j; j *= 10; } if (a[0] == '-') { A = -A; } //printf("%d ", A); long long B = 0; for (i = strlen(&b) - 1, j = 1; i >= 0; i--) { if (b[i] == ',' || b[i] == '-') { continue; } B+= (b[i] - '0') * j; j *= 10; } if (b[0] == '-') { B = -B; } printf("%d\n", A+B); // printf("%s:%d\n",b,strlen(&b)); } return 0; }