谁可以帮忙看看问题出在哪了?显示RE

P1035 [NOIP2002 普及组] 级数求和

aaaa___ @ 2018-07-25 19:26:33

include<cstdio>

using namespace std; int main() { int n=0,t=0,k; double Sn; scanf("%d",k); while(Sn<=k) {

  ++n;
  t=1/n;
  Sn+=t;

} printf("%d",n); return 0; }


by aaaa___ @ 2018-07-25 19:28:06

include<cstdio>

using namespace std; int main() { int n=0,t=0,k; double Sn; scanf("%d",k); while(Sn<=k) {

  ++n;
  t=1/n;
  Sn+=t;

} printf("%d",n); return 0; }


by liutianze @ 2018-07-25 19:39:38

好像没问题


by liutianze @ 2018-07-25 19:39:51

----我看啊看--------


by Smile_Cindy @ 2018-07-25 19:54:36

1/n是整除,肯定是0


by Smile_Cindy @ 2018-07-25 19:54:50

所以t也是0


by aaaa___ @ 2018-07-25 21:02:46

@liutianze ·-·


by aaaa___ @ 2018-07-25 21:03:58

@Alpha 666 请问怎么解决


by Smile_Cindy @ 2018-07-25 23:10:31

把1/n改成1.0/n


by Smile_Cindy @ 2018-07-25 23:10:56

把t改成double


by aaaa___ @ 2018-07-26 12:30:52

@Alpha 试了但是没用诶,还是RE


| 下一页