Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
102895 万隽宇 二进制转十进制 C++ Accepted 1 MS 284 KB 440 2024-12-26 19:14:52

Tests(20/20):


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(){ char n[100]; cin>>n; int j=strlen(n),a=0; for(int i=0,k=j-1;i<j&&k>=0;i++,k--){ a+=(n[k]-'0')*pow(2.0,i); } cout<<a; return 0; }