1 条题解
-
0
【例12.3】甲流疫情死亡率
解题思路
死亡率为死亡数/确诊数×100,保留三位小数后加百分号。
正确性说明
比例乘 100 转为百分数数值,按题目格式输出。
易错点
第二个输入才是死亡数;百分号紧跟数值。
复杂度
本题输入规模固定,时间 O(1),额外空间 O(1)。
参考代码(C++11)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); double cases, deaths; cin >> cases >> deaths; cout << fixed << setprecision(3) << deaths / cases * 100 << "%\n"; return 0; }
- 1