Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
73784 程余天皓 二进制转十进制 C++ Compile Error 0 MS 0 KB 301 2024-05-19 16:47:16

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ string n; cin>>n; int len=n.size(); int a[len]; int j=0; for(int i=len-1;i>=0;i--){ a[j]=n[i]-"0"; j++; } int sum=0; for(int i=0;i<len;i++){ sum+=pow(2,i)*a[i]; //cout<<a[i]<<" "; } cout<<sum; return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:10:13: error: invalid operands of types '__gnu_cxx::__alloc_traits >::value_type {aka char}' and 'const char [2]' to binary 'operator-'
   a[j]=n[i]-"0";
             ^