~~~题目链接~~~
大数乘法
#include <stdio.h> #include <string.h> int main() { int i = 0, j = 0, len = 0, len1 = 0, len2 = 0, n1[252], n2[252], n3[505]; char s1[252], s2[252]; while(scanf("%s %s", s1, s2) != EOF) { memset(n1, 0, sizeof(n1)); memset(n2, 0, sizeof(n2)); memset(n3, 0, sizeof(n3)); len1 = strlen(s1); len2 = strlen(s2); for(i = 0; i<len1; i++) n1[i] = s1[len1-i-1]-'0'; for(i = 0; i<len2; i++) n2[i] = s2[len2-i-1]-'0'; for(i = 0; i<len1; i++) for(j = 0; j<len2; j++) n3[i+j] += n1[i]*n2[j]; len = len1+len2; for(i = 0; i<len; i++)//进位 { if(n3[i]>=10) { n3[i+1] += n3[i]/10; n3[i] %= 10; } } while(n3[len] == 0 && len>-1) len--; while(len>-1) printf("%d", n3[len--]); printf("\n"); } return 0; }