zjut 1046 绩点计算

//我觉得这题出得不是很好,因为输入的数目有很大的分歧,没有给出一个具体的数!
//下面的代码是我参照别人的代码之后,再自己写出的!感觉这题除了输入有点难搞之后,其他的还是比较简单的!
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
using namespace std;

struct Info
{
	string name;
	int score1;
	int score2;
	int score3;
	double point;
};

bool mycomp(Info a, Info b)
{
	return a.point > b.point;
}

int main()
{
	vector<Info> v;
	vector<Info>::iterator it;
	string temp;
	for(int s1, s2, s3; cin >> temp >> s1 >> s2 >> s3;)
	{
		Info ans;
		ans.name = temp;
		ans.score1 = s1;
		ans.score2 = s2;
		ans.score3 = s3;
		if (ans.score1 < 60)
			ans.score1 = 50;
		if (ans.score2 < 60)
			ans.score2 = 50;
		if (ans.score3 < 60)
			ans.score3 = 50;
		double jidian = ((ans.score1 - 50) * 1.0 / 10 * 3 + (ans.score2 - 50) * 1.0 / 10 * 3 + (ans.score3 - 50) * 1.0 / 10 * 4) / 10;
		ans.point = jidian;
		v.push_back(ans);
	}

	sort(v.begin(), v.end(), mycomp);
	for (it = v.begin(); it != v.end(); it++)
		cout << it->name << " " << it->score1 << " " << it->score2 << " " << it->score3 << endl;
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值