hct_ @ 2022-11-17 18:50:54
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
double n,m,cnt=0;
cin >>n;
for (int i=1;i<=n;i++){
cnt+=1/i;
}
cout <<fixed << setprecision(2)<<cnt;
return 0 ;
}
求大佬解答
by HarunluoON @ 2022-11-17 18:55:34
cnt+=1/i;
除法请用cnt+=1.0/i;
by hct_ @ 2022-11-18 17:53:58
@HarunluoON 谢谢大佬指点!
by hct_ @ 2022-11-18 18:10:47
该死,看错题目了(悲