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 |
为什么runtime error? 想不明白.. 会有人看我的代码么? 渺茫..#include <iostream> using namespace std; char octal[1002]; int deci[3002]; int main() { freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); while(scanf("%s",octal)!=EOF) { int leno=strlen(octal); int o; for(o=0;o<leno;++o) if(octal[o]!='0'&&o!=1) break; if(o==leno) { printf("%s [8] = 0 [10]\n",octal); continue; } else if(octal[0]=='1') { printf("%s [8] = 1 [10]\n",octal); continue; } memset(deci,0,sizeof(deci)); deci[3001]='.'; int r=8; for(int i=2;i<leno;++i) { int t=octal[i]-'0'; t*=10; int p=2; while(t%r!=0) { deci[3002-p]+=t/r; t=(t%r)*10; p++; } deci[3002-p]+=t/r; r*=8; } int stop=0; while(!deci[stop]) stop++; int c=0; int j=stop; while(j<3001) { c=deci[j]+c; deci[j]=c%10; c/=10; j++; } printf("%s [8] = 0.",octal); for(int i=3000;i>=stop;--i) printf("%d",deci[i]); printf(" [10]\n"); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator