#include<iostream> #include<string> #include<cmath> #include<cstring> #include<iomanip> using namespace std; int main() { char s[30]; while (scanf("%s",s)!=EOF) { int len = strlen(s); long double sum = 0; int cnt = len - 2; for (int i = 2;i < len;i++) { long double z = pow(8, i - 1); int a = s[i] - '0'; long double m = a / z; //cout << m << endl; sum += m; } printf("%s [8] = %.50g [10]\n", s, sum); } } /* F:\temp\23355141.193258\Main.cc: In function 'int main()': F:\temp\23355141.193258\Main.cc:11: error: 'scanf' was not declared in this scope F:\temp\23355141.193258\Main.cc:11: error: 'EOF' was not declared in this scope F:\temp\23355141.193258\Main.cc:24: error: 'printf' was not declared in this scope */ |
Double click to view unformatted code.