#include<stdio.h>
#include<string.h>
int main()
{
int t;
char a[100], b[100];
scanf("%d", &t);
for (int cn=0;cn<t;cn++)
{
int c[300] = { 0 };
scanf("%s %s", a,b);
int n1 = strlen(a);
int n2 = strlen(b);
int cnt = 0,digit=0;
for(int i=n1-1;i>=0;i--)
{
for (int j = n2 - 1; j >= 0; j--)
{
c[cnt] += (a[i] - 48) * (b[j] - 48);
c[cnt+1] += c[cnt] / 10;//进位
c[cnt] %= 10;
cnt++;
if (digit < cnt)digit = cnt;
}
cnt = n1 - i;
}
printf("Case %d:\n%s * %s = ",cn+1,a,b);
while (c[digit] == 0&&digit>0)digit--;
for (int i = digit; i >= 0; i--)
{
printf("%d", c[i]);
}
printf("\n\n");
}
return 0;
}
A × B problem【大数乘法】
于 2022-11-02 14:37:16 首次发布