Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位大虾指导一下代码感觉对,不过DEBURG,检查不出来!哪位能解释一下? #include <iostream.h> #include <string.h> #include <math.h> #include <stdio.h> char result[200]; char hold[200]; void main() { char s[7]; int n,len=0,pointnum=0; while(cin>>s>>n){ long num=0; result[0]='1'; for(int j=0;j<6;j++) if(s[j]<='9'&&s[j]>='0') { num*=10; num+=s[j]-'0'; } if(s[1]=='0') pointnum=4; else pointnum=3; pointnum=pow(pointnum,n); while(n--){ for(int k=0;k<200;k++) //去小数点,按整数值乘法 { sprintf(hold,"%ld",(result[k]-'0')*num*pow(10,k)); len=strlen(hold); for(int l=0;l<len;l++) { result[l]+=hold[l]; if(result[l]>9) result[l+1]++; } } } for(int m=199;m>=pointnum;m--) if(result[m]!=0) cout<<result[m]; cout<<"."; for(int q=pointnum-1;q>=0;q--) if(result[q]!=0) cout<<result[q]; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator