为什么flaot通过不了呢!

P1035 [NOIP2002 普及组] 级数求和

gkk276966188 @ 2019-04-29 09:20:39

include<stdio.h>

int main() { int i=0, x; float n = 0,y; scanf_s("%d", &x, 1); do { i++; n = n + 1.0 / i; } while (n<=float(x)); printf("%d", i); return 0; }


by Smile_Cindy @ 2019-04-29 09:41:08

@gkk276966188

希望更丰富的展现?使用Markdown


by Azazеl @ 2019-04-29 13:49:08

include<stdio.h>
int main() 
  { 
  int i=0, x; 
  float n = 0,y; 
  scanf_s("%d", &x, 1); 
  do 
  { i++; 
  n = n + 1.0 / i; 
  } while (n<=float(x)); 
                        printf("%d", i); return 0; }

还原完毕


by 暴雪海南 @ 2019-07-25 09:13:34

用double呀


by 暴雪海南 @ 2019-07-25 09:13:52

@gkk276966188


|