90*0.3为什么能算成26??

P3954 [NOIP2017 普及组] 成绩

Talk is cheap,show me your code.
by qifan_maker @ 2024-03-12 20:13:23


@[q789456](/user/1304144) 看清楚再说。 > 总成绩是 $60\times20\%+\color{red}90\times30\%\color{black}+80\times50\%=12+\color{red}27\color{black}+40=79$
by wzj0829 @ 2024-03-12 20:16:19


@[q789456](/user/1304144) 应为你要用高精,而不是 `double`。(逃)
by XuYueming @ 2024-03-12 20:18:40


AC Code: ```cpp #include <iostream> #include <cmath> using namespace std; int a, b, c; int main() { cin >> a >> b >> c; cout << a * 0.2 + b * 0.3 + c * 0.5; } ```
by lovely_codingcow @ 2024-03-12 20:20:11


@[qifan_maker](/user/706607) 代码发不出去 一发就显示错误
by q789456 @ 2024-03-12 20:27:21


@[q789456](/user/1304144) ```cpp #include <bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; int cj; cj=a*0.2+b*0.3+c*0.5; cout<<cj; return 0; } ``````
by q789456 @ 2024-03-12 20:30:08


@[q789456](/user/1304144) 小数记得用 `double`。 ```cpp #include <bits/stdc++.h> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; double cj; cj=a*0.2+b*0.3+c*0.5; cout<<cj; return 0; } ```
by qifan_maker @ 2024-03-12 20:32:15


@[qifan_maker](/user/706607) 谢谢
by q789456 @ 2024-03-12 20:33:42


|