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> #include <cstdio> #include <cstring> using namespace std; int main() { char s[200]; int sc[100],t[200]; while(scanf("%s",s)!=EOF) { printf("%s [8] = 0.",s); memset(sc,0,sizeof(sc)); int len=strlen(s),i,j; for(j=0,i=len-1;i>=2;i--) t[j++]=s[i]-'0'; len-=2; for(i=0;i<len;i++) { int c=0; sc[i]+=t[i];//这步很关键哦 for(j=0;j<=len+2;j++) { sc[j]=sc[j]*125+c; c=sc[j]/1000; sc[j]%=1000; } } for(i=len-1;i>=0;i--) printf("%03d",sc[i]); cout<<" [10]"<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator