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