| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 153358 | 陈骏睿 | 二进制小数转十进制 | C++ | Compile Error | 0 MS | 0 KB | 543 | 2026-05-16 12:00:21 |
#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=a.size; int i=0; double 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; }
Main.cc: In function 'int main()':
Main.cc:10:11: error: cannot convert 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size, std::allocator >' from type 'std::__cxx11::basic_string::size_type (std::__cxx11::basic_string::)() const noexcept {aka long unsigned int (std::__cxx11::basic_string::)() const noexcept}' to type 'int'
int l=a.size;
^