Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
128622 | 罗迎甲 | 二进制小数转十进制 | C++ | Accepted | 1 MS | 284 KB | 359 | 2025-08-18 16:59:38 |
#include<bits/stdc++.h> using namespace std; int main() { double sum=0; char a[64]; cin>>a; int len=strlen(a); double s=1; int i=0; while(a[i]!='.'&&i<len)i++; for(int j=i-1;j>=0;j--){ sum+=(s*(a[j]-'0')); s*=2; } s=2; for(i+=1;i<len;i++){ sum+=((1/s)*(a[i]-'0')); s*=2; } cout<<sum<<endl; return 0; }