2016-08-18 Problem Solving►UVa UVa 424 - Integer Inquiry Contents 1. Problem2. Solution3. Code Problem中文網址 Solution單純做大數。 CodeUVa 4241234567891011121314151617181920212223242526272829303132333435#include<stdio.h>#include<string.h>#define N 110int main() { char s[N]; int sum[N] = { 0 }; int i; while (fgets(s, N, stdin) && !(s[0] == '0'&&s[1] == '\0')) { int len = strlen(s) - 1; s[len] = NULL; for (i = 0; i < len; i++) { sum[i] += s[len - i - 1] - '0'; if (sum[i] >= 10) { sum[i + 1] += sum[i] / 10; sum[i] %= 10; } } } for (i = N - 1; i >= 0 && !sum[i]; i--); while (i >= 0) printf("%d", sum[i--]); putchar('\n'); return 0;} Newer UVa 11716 - Digital Fortress Older UVa 11727 - Cost Cutting