#include <stdio.h>
#include <string.h>
#define N 1000
void printit(int* a, int n) {
int i = 0;
while (a[i] == 0) i++;
for (; i < n; i++) printf("%d", a[i]);
printf("\n");
}
void stoarr(char* s, int* a, int n) {
int i, m;
for (i = 0; i < n; i++) a[i] = 0;
m = strlen(s);
for (i = 0; i < m; i++)
a[n - m + i] = s[i] - '0';
}
void addarr(int* a, int* b, int* c, int n) {
int i, m = 0;
for (i = 0; i < n; i++) c[i] = a[i] + b[i];
for (i = n - 1; i >= 0; i--) {
c[i] += m;
m = c[i] / 10;
c[i] %= 10;
}
}
void mularr(int* a, int* b, int* c, int n) {
int i, j, m;
for (i = 0; i < n; i++) c[i] = 0;
for (i = n - 1; i >= 0; i--)
for (j = n - 1; j >= 0; j--) {
m = i + j - n + 1;
if (m >= 0) c[m] += a[i] * b[j];
}
m = 0;
for (i = n - 1; i >= 0; i--) {
c[i] += m;
m = c[i] / 10;
c[i] %= 10;
}
}
int main() {
int a[N], b[N], c[N];
char s[N];
printf("输入第一个大数\n");
gets(s);
stoarr(s, a, N);
printf("输入第二个大数\n");
gets(s);
stoarr(s, b, N);
addarr(a, b, c, N);
printf("两数之和是:\n");
printit(c, N);
mularr(a, b, c, N);
printf("两数之积是:\n");
printit(c, N);
}