//我觉得这题出得不是很好,因为输入的数目有很大的分歧,没有给出一个具体的数!
//下面的代码是我参照别人的代码之后,再自己写出的!感觉这题除了输入有点难搞之后,其他的还是比较简单的!
#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;
}
zjut 1046 绩点计算
最新推荐文章于 2021-10-18 20:08:11 发布