@@ -1,14 +1,20 @@
|
|||||||
#include "iostream"
|
#include "iostream"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//最小的n
|
int n, r, s = 0, t = 1;
|
||||||
float s=0,n=1;
|
|
||||||
int main() {
|
int main() {
|
||||||
while (s<5) {
|
cin >> n;
|
||||||
s=s+1/n;
|
while (n > 0) {
|
||||||
n++;//n=n+1 n+=1
|
r = n % 10; // 将原数的最后一位取出
|
||||||
//cout <<s<<"|"<<1.0/n<<"|"<<n<<endl;
|
n = n / 10;
|
||||||
|
if (r == 0) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
s += r * t; // 将 尾数r 乘上 位权 加到 新数s里
|
||||||
|
t *= 10; // 下一次的数字在更高一位
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cout <<n<<endl;
|
cout << s << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user