您当前的位置: 首页 >  Python

2020年第十一届蓝桥杯 - 省赛 - Python大学组 - F.成绩统计

发布时间:2022-01-06 09:11:35 ,浏览量:0

在这里插入图片描述 在这里插入图片描述

Ideas

这题基本就是纯统计的活,没什么算法。

注意用四舍五入函数round就可以了。

同时C++注意要做类型转换。

Code C++
#include  #include   using namespace std; int main() { int n, n1 = 0, n2 = 0; cin >> n; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; if (tmp > 59) { n1++; } if (tmp > 84) { n2++; } } cout << round(100.0 * n1 / n) << "%" << endl; cout << round(100.0 * n2 / n) << "%" << endl; return 0; } 
Python
n = int(input()) n1, n2 = 0, 0 for i in range(n): score = int(input()) if score >= 85: n1 += 1 if score >= 60: n2 += 1 print(f"{round(100 * n2 / n)}%") print(f"{round(100 * n1 / n)}%") 
关注
打赏
1688896170
查看更多评论

暂无认证

  • 0浏览

    0关注

    108697博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0490s