Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
153352 陈骏睿 二进制小数转十进制 C++ Compile Error 0 MS 0 KB 547 2026-05-16 11:53:29

Tests(0/0):


Code:

#include<iostream> // cin\cout\endl #include<cstdio> //scanf()\printf() #include<cstring> // strcpy()\strcat()\strcmp()\strlen()\memset() #include<cmath> //sqrt()\pow()\abs()\ceil()\floor()\max()\min() using namespace std; int main(){ string a; cin>>a; int l=strlen(a); int i=0; bouble n=0,p=1; while(a[i]!='.'&&i<l)i++; for(int j=l-1;j>=0;,j--){ n+=(a[j]-'0')*p; p*=2; } p=2; for(i=i+1;i<l;i++){ n+=(a[1]-'0')*(1/p); p*=2; } cout<<n<<endl; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:10:17: error: cannot convert 'std::__cxx11::string {aka std::__cxx11::basic_string}' to 'const char*' for argument '1' to 'size_t strlen(const char*)'
   int l=strlen(a);
                 ^
Main.cc:12:3: error: 'bouble' was not declared in this scope
   bouble n=0,p=1;
   ^
Main.cc:14:22: error: expected primary-expression before ',' token
   for(int j=l-1;j>=0;,j--){
                      ^
Main.cc:15:7: error: 'n' was not declared in this scope
       n+=(a[j]-'0')*p;
       ^
Main.cc:15:21: error: 'p' was not declared in this scope
       n+=(a[j]-'0')*p;
                     ^
Main.cc:18:4: error: 'p' was not declared in this scope
    p=2;
    ^
Main.cc:20:7: error: 'n' was not declared in this scope
       n+=(a[1]-'0')*(1/p);
       ^
Main.cc:23:10: error: 'n' was not declared in this scope
    cout<