Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
93988 | 只因你太美(Ikun 真爱粉) | 二进制小数转十进制 | C++ | Accepted | 1 MS | 280 KB | 593 | 2024-10-19 16:59:48 |
#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(){ string str; cin>>str; int len=str.length(); double po=1,an=0; int i=0; while(str[i]!='.'&&i<len)i++; for(int k=i-1;k>=0;k--){ an+=(po*(str[k]-'0')); po*=2; } po=2; for(i+=1;i<len;i++){ an+=((1/po)*(str[i]-'0')); po*=2; } cout<<an; return 0; }