question:http://poj.org/problem?id=1001
1#include <iostream>2 using namespacestd;3 #defineMax 10004 CharA[max];5 CharB[max];6 CharC[max];7 intMain ()8 {9Memset (A,0, +*sizeof(Char));Tenmemset (b,0, +*sizeof(Char)); OneMemset (c,0, +*sizeof(Char)); A Char*r= (Char*)malloc(6*sizeof(Char)); - intN,point; - while(cin>>r>>N) the { - for(intI=5, j=0; i>=0; I--, J + +) - { - if(r[i]=='.') + { -Point=5-i; +j--; A Continue; at } -a[j]=R[i]; -b[j]=R[i]; - } - - if(n==1) in { - strcpy (c,a); to } + Else - { the for(intk=1; k<n;k++) * { $ intalen=strlen (a);Panax Notoginseng intblen=strlen (b); - intM,n; the intjw=0; + for(m=0; m<alen+blen;m++) A { the inttemp=0; + for(N= (m-blen+1) >0? (m-blen+1):0); n<alen&&m-n<blen&&m-n>=0; n++) - { $temp+= (a[n]-'0') * (b[m-n]-'0'); $ } -temp+=JW; -jw=temp/Ten; thetemp%=Ten; -c[m]=temp+'0';Wuyi } the strcpy (a,c); - } Wu } - intslen=strlen (c); About intQ; $ for(Q=strlen (c)-1; c[q]=='0'&&q>=point*n;q--) - { -c[q]=0; - } A for(q=0; c[q]=='0'&&q<point*n;q++) + { the } - for(intP=strlen (c)-1;p >=q;p--) $ { the if(p==point*n-1) the { thecout<<"."; the } -cout<<C[p]; in } theMemset (A,0, +*sizeof(Char)); thememset (b,0, +*sizeof(Char)); AboutMemset (c,0, +*sizeof(Char)); thecout<<Endl; the } the return 0; +}
PKU ACM (QUESTION-1001)