标签:style blog color io ar for sp div c
#include<stdio.h> #include<string.h> #include<math.h> int c[501],a[501],b[501],n,nn,nl,i,j,flag,temp[501],temp1[501]; char s[501],s2[501]; void input () { scanf("%s ",&s); scanf("%s ",&s2); n=strlen(s)-1; for(i=0;i<=n;i++) a[i]=s[n-i]-‘0‘; nn=strlen(s2)-1; for(i=0;i<=nn;i++) b[i]=s2[nn-i]-‘0‘; } void calc(){ for(i=0;i<=n;i++) for(j=0;j<=nn;j++) c[i+j]+=a[i]*b[j]; nl=n>nn? n:nn; int t; t=0; for(i=0;i<=n+nn;i++) { if(c[i]>=10) { t=c[i]/10; c[i]-=t*10; c[i+1]+=t; } } nl=n+nn+2; for(i=nl;;i--) { int k=i ; if(c[k]==0)nl--; else break; } } int main() { input(); calc(); for(i=nl;i>=0;i--) printf("%d",c[i]); return 0; }
标签:style blog color io ar for sp div c
原文地址:http://www.cnblogs.com/z52527/p/4002057.html