蓝桥杯成绩统计

原题链接 

2871. 成绩统计 - AcWing题库https://www.acwing.com/problem/content/description/2874/

 除法实现四舍五入:C语言实现四舍五入_Spf小鱼干-CSDN博客_c语言四舍五入icon-default.png?t=M1L8https://blog.csdn.net/weixin_38505045/article/details/79994536

#include<iostream>
using namespace std;
const int N = 10010;
int main()
{
	int n;cin>>n;
	float jige=0.0,youxiu=0.0;//人数 
	for(int i =0;i<n;i++)
	{
		int g;cin>>g;
		if(g>=85)
		{
			jige++;
			youxiu++;
		}
		else if(g>=60)
			jige++;		 
	}
	float j1 = jige/n*100;
	int j2 = j1;
	if((j1-j2)>=0.5)
		cout<<(j2+1)<<"% ";
	else
		cout<<j2<<"% ";
	float y1 = youxiu/n*100;
	int y2 = y1;
	if((y1-y2)>=0.5)
		cout<<(y2+1)<<"%";
	else
		cout<<y2<<"%";
	return 0;
} 

#include<iostream>
using namespace std;

int main(){
    int T;
    int sum_85 = 0, sum_60 = 0;
    cin >> T;
    int n = T;
    while(T--){
    	int score;
        cin>>score;
        if(score >= 85) sum_85 ++;
        if(score >= 60) sum_60 ++;
    }
    
    printf("%d%%\n%d%%", int(float(sum_60) * 100 / n + 0.5), int(float(sum_85) * 100 / n + 0.5));
    return 0;
}
————————————————
版权声明:本文为CSDN博主「和BUG做朋友的ZORO」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_45914759/article/details/114103305

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值