//
// Created by Cauchyshy on 2023/5/3.
//
#include <bits/stdc++.h>
using namespace std;
class Person {
public:
string name;
int score;
Person(string name, int score) {
this->name = name;
this->score = score;
}
};
void create(vector<Person> &v) {
string k = "ABCDE";
for (int i = 0; i < 5; ++i) {
string name = "选手";
name += k[i];
int sc = 0;
v.push_back({name, sc});
}
}
void print(const vector<Person> &v) {
for (auto &i : v) {
cout << i.name << " " << i.score << "\n";
}
}
void setScore(vector<Person> &v) {
deque<int> d;
for (auto &V : v) {
for (int i = 0; i < 10; ++i) {
int sc = rand() % 101; // [0-100]
d.push_back(sc);
}
sort(d.begin(), d.end());
d.pop_front();
d.pop_back();
int sum = 0;
for (auto &it : d) sum += it;
int avg = sum / d.size();
V.score = avg;
}
}
void showScore(const vector<Person> &v) {
for (auto &it : v) {
cout << "name->" << it.name << " 平均分->" << it.score << "\n";
}
}
void test() {
srand((unsigned int)time(NULL));
vector<Person> ve;
create(ve);
// print(ve);
setScore(ve);
showScore(ve);
}
int main() {
test();
return 0;
}
c++评委打分
最新推荐文章于 2024-07-01 11:02:03 发布