11 条题解
-
0
题目描述
甲流并不可怕,在中国,它的死亡率并不是很高。请根据截止2009年12月22日各省报告的甲流确诊数a和死亡数b,计算甲流在各省的死亡率。
输入2行:第1行a,第2行b 输出1行:甲流死亡率,以百分数形式输出,精确到小数点后3位
注意事项
- 小数形式的死亡率(b/a)
- 转化为百分比的形式(*100)
- 别忘了加上百分号(%),shift+5
AC代码
#include <bits/stdc++.h> using namespace std; int main() { double a,b; cin >> a; cin >> b; cout << fixed << setprecision(3) << b/a*100 << "%"; return 0; }
-
0
题目分析
可以说,这算是一个数学百分比问题,主要求【死亡数】占【确诊数】的百分比。 可以理解为【确诊数】是总数,而【死亡数】是总数中的一部分。那么:
【死亡率】=【死亡数】÷【确诊数】
如何转为百分数?我们知道
1÷100=0.01,也表示1占了100的0.01,也就是1%。
其实就是把0.01×100,再加上一个百分号%,就等于1%,所以0.01=1%
同理50÷100=0.5,也等于50%
那么,在写代码时,把结果乘以100,再加一个百分号%即可。
注意!C++是没有百分数的写法。
#include<bits/stdc++.h> using namespace std; int main() { int a,b; cin>>a>>b; cout<<fixed<<setprecision(3); cout<<100.0*b/a<<'%'; return 0; }
- 1
信息
- ID
- 82
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 4
- 标签
- 递交数
- 594
- 已通过
- 266
- 上传者