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 |
为什么程序交上去就出错?电脑上能用呀#include <iostream> using namespace std; int f[150],n,g,i,j,k,l,m,p; double r; int main() { while(cin>>r>>n) { if(r>=10){p=3;g=int(r*1000);} else{p=4;g=int(r*10000);} memset(f,0,sizeof(f)); f[0]=1; m=0; k=0; p=p*n; while(n>0) { for(i=0;i<=m;i++) f[i]=f[i]*g; i=0; while(i<=m) { if(f[i]>9) { f[i+1]+=f[i]/10; f[i]=f[i]%10; m=m>?(i+1); } i++; } k=m; n--; } for(i=0;i<p;i++) if(f[i]!=0)break; if(f[i]!=0) { for(j=m;j>=p;j--) cout<<f[j]; cout<<'.'; for(j=p-1;j>=i;j--) cout<<f[j]; cout<<endl; } else { if(m>=p) { for(j=m;j>=p;j--) cout<<f[j]; } else cout<<0; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator