Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
69254 | 李琥博 | 二进制小数转十进制 | C++ | Accepted | 0 MS | 276 KB | 305 | 2024-03-31 12:13:03 |
#include<bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; int b=0,c=0,z=0,n=s.size(),d=s.find("."); double a=0; for(int i=d-1;i>=0;i--){ b+=(s[i]-48)*pow(2,c); c++; } c=-1; for(int i=d+1;i<n;i++){ a+=(s[i]-48)*pow(2,c); c--; } cout<<a+b; return 0; }