c++ - 整数和浮点数的相互转化运算的问题?
迷茫
迷茫 2017-04-17 13:38:03
0
2
570

将for循环里面的 double 换成 int 就不能运行了

这就是将double 换成 int 后的结果了

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
黄舟

is no problem originally, but the n and m you input here are too large, and the integer overflows, causing i * i to become 0 after overflow, and a division-by-zero exception in the denominator occurs.

洪涛

1/(i*i) is the division of two integers (in this case, 1/3 is not equal to 0.3333... but equal to 0), I think you need to use 1.0/(i*i) for this. Since i*i may indeed be 0, you'd better judge ahead of time.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template