Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
128629 林嘉乐 二进制小数转十进制 C++ Compile Error 0 MS 0 KB 561 2025-08-18 17:04:21

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(){ double s=0; double q=1; char a[64]; cin>>a; int l=strlen(a); int i=0; while(a[i]!='.'&&i<l)i++; for(int j=i-1;j>=0;j--){ s+=(p*a[j]-'0'); p*=2; } p=2; for(i+=1;i<l;i++){ s+=((1/p)*(a[i]-'0')); p*=2; } cout<<s; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:16:10: error: 'p' was not declared in this scope
      s+=(p*a[j]-'0');
          ^
Main.cc:19:5: error: 'p' was not declared in this scope
     p=2;
     ^
Main.cc:9:12: warning: unused variable 'q' [-Wunused-variable]
     double q=1;
            ^