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.h> const NN=1000; void main(){ double R; int n=0,m=0; int l=4; int sum[100]; char r[6]; int xs=0; // 输入 for(int ii=0;ii<6;ii++){ cin>>r[ii]; if(r[ii]>='0' &&r[ii]<='9')m=m*10+r[ii]-'0'; if(r[ii]=='.')xs=ii; } if(xs>=2)m=m*10; cin>>n; for(int i=0;i<100;i++)sum[i]=0; sum[0]=m%NN; sum[1]=m/NN; int n1=1,n2=0; // int s1=0,s2=0; if (sum[n2]==0)n2++; if (sum[n1]!=0)n1++; for (i=1;i<n;i++){ for(int j=0,s1=0,s2=0;j<100;j++){ s1=sum[j]*m+s2; s2=s1/NN; sum[j]=s1%NN; } } for(n1=99;n1>=0 && sum[n1]==0;n1--); l=l*n; int out[150]; int cn=0; //n1++; if (sum[n1]>=100){out[cn]=sum[n1]/100;cn++;} if (sum[n1]>=10){out[cn]=(sum[n1]-sum[n1]/100*100)/10;cn++;} out[cn]=sum[n1]%10; for (n=n1-1;n>=0;n--){ out[++cn]=sum[n]/100; out[++cn]=(sum[n]-sum[n]/100*100)/10; out[++cn]=sum[n]%10; } for(n2=cn;(cn-l)<n2 && out[n2]==0;n2--); //输出 if(l>cn)cout<<'.'; for(int count=1 ;l>cn+count;count++)cout<<0; for(n=0;n<=n2;n++){ if(l<=cn)if(cn-n+1==l)cout<<'.'; cout<<out[n]; } cout<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator