| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 140005 | 李朋秦 | 二进制小数转十进制 | C++ | Wrong Answer | 0 MS | 280 KB | 396 | 2025-12-13 14:26:54 |
#include<bits/stdc++.h> using namespace std; int main(){ string a;double c=0;int n=0,m=0; cin>>a; int x=a.size(); for(int i=0;i<x;i++){ if(a[i]!='.')n++; else break; }for(int i=n+1;i<x;i++){ m++; } for(int i=n-1,j=0;i>=0,j<=n-1;i--,j++){ c+=(a[i]-'0')*(pow(2,j)); } for(int i=n-2,j=-1;i<=m,j>=0-1-m;i++,j--){ c+=(a[i]-'0')*(pow(2,j)); }cout<<c; return 0; }
------Input------
0.111
------Answer-----
0.875
------Your output-----
-24.1875