#include<stdio.h> #include<stdlib.h> #include<string.h> char result[200]; void mulStr(char *str, char *one, char* two) { char *str1 = one; char *str2 = two; if(!strcmp(str1,"0")||!strcmp(str2,"0")) { strcpy(str,"0"); return; } bool sinal = true; int len1 = strlen(str1); int len2 = strlen(str2); if(*str1=='-') { len1--; str1++; sinal = !sinal; } if(*str2=='-') { len2--; str2++; sinal = !sinal; } int i,j; int carry=0, out=0,addition; char *result = str; memset(result,'0',len1+len2+1); for(i=len1-1;i>=0;i--) { for(j=len2-1;j>=0;j--) { out = (*(str1+i)-'0')*(*(str2+j)-'0')+carry+*(str+len1+len2-i-j-2)-'0'; *(str+len1+len2-i-j-2) = out%10 + '0'; carry = out/10; } *(str+len1-i+len2-1) = carry +'0'; carry = 0; } char *pend = result + len1 + len2 -1; if(*pend=='0') { if(!sinal) { *pend = '-'; *(pend+1) = 0; pend++; } else { *pend = 0; pend--; } } else { if(!sinal) { *(pend+1) = '-'; *(pend+2) = 0; pend++; } else { *(pend+1)=0; } } char ch; while(result<pend) { ch = *pend; *pend = *result; *result = ch; result++; pend--; } return ; } int main() { char str1[100]; char str2[100]; char result[200]; while(~scanf("%s %s", str1,str2)) { mulStr(result,str1,str2); printf("%s ",result); } return 0; }