You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
644 B

#include <bits/stdc++.h>
using namespace std;
// double类型用==判断相等为什么不行
// https://blog.csdn.net/m0_38125278/article/details/89026537
//Epslion在希腊符号中代表一个极小数的意思这里取1*10的-8次幂
#define Epslion 1e-8
int main() {
double n;
cin >> n;
//个数
int count = 0;
//暂存数组
int a[10] = {0};
while (true) {
n *= 2;
int jiInt = (int) n;
a[count++] = jiInt;
n -= jiInt;
//小于一定的精度
if (n < Epslion) break;
}
cout << "0.";
for (int i = 0; i < count; i++) {
cout << a[i];
}
return 0;
}