跪谢
by Chloe_Cipher @ 2020-02-03 20:17:27
@[Chloe_Cipher](/user/289757)
` printf("&.1f\n",money);`
也许需要 ` printf("&.1lf\n",money);` ?
不确定……这方面有些东西很玄学……
by Wenoide @ 2020-02-03 20:27:51
四舍五入,四舍五入,四舍五入
(我也是一个刚入C++的萌新,写了一个垃圾四舍五入算法,不介意的话可以拿去用XD)
```cpp
if(电费 >= floor(10 * 电费) / 10 + 0.05) 电费 = ceil(10 * 电费) / 10;
else 电费 = floor(10 * 电费) / 10;
//使用这个算法需要在头文件些#include<cmath>
//我不知道这个用printf("%.1f",电费)能不能AC...
```
by cmaths @ 2020-02-03 20:28:05
@[伦理道德](/user/300098)
`printf` 理论上可以
by Wenoide @ 2020-02-03 20:29:11
@[伦理道德](/user/300098) 反正我用我写的这个算法AC了
by cmaths @ 2020-02-03 20:30:10
@[伦理道德](/user/300098) 谢谢谢谢谢谢谢!!!!!!!!
by Chloe_Cipher @ 2020-02-03 20:31:35
@[ScanfN](/user/118228) 谢谢谢谢谢谢谢!!!!!!!!!!!!!!!!
by Chloe_Cipher @ 2020-02-03 20:31:53
@[伦理道德](/user/300098)
话说现在似乎都没人用 `setprecision` 了
by Wenoide @ 2020-02-03 20:32:23
@[ScanfN](/user/118228) 我用printf("&.1f\n",money);AC了!
by cmaths @ 2020-02-03 20:34:00
@[Chloe_Cipher](/user/289757) 如果你是c++党:setprecision(这个单词有点长,CE别怪我)
by SIXIANG32 @ 2020-02-03 20:41:00