POJ 1131
#include <iostream> #include <string> using namespace std; int ans[3000]; int main() { //freopen("acm.acm","r",stdin); string s; int index; int i; int j; int c; int r; while(cin>>s) { index = 1; for(i = s.length()-1; i > 1; -- i) { ans[0] += s[i]-'0'; c = 0; r = 0; for(j = 0; j < index; ++ j) { c = (ans[j]+r*10)/8; r = (ans[j]+r*10)%8; ans[j] = c; } while(r) { ans[j] = (r*10)/8; r = (r*10)%8; ++ j; } index = j; } c = 0; cout<<s<<" [8] = 0."; for(i = 1; i < index; ++ i) { cout<<ans[i]; } cout<<" [10]"<<endl; } }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com