using namespace std; int main() { double k; int n=0; double sn=0; //使用double精度 cin>>k; while (sn<=k) //知道不满足跳出 { n++; sn+=1.0/n; //是+= 先加后等于!
}