Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2017 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1ff3d20de316fd6b3d4b4839bc6c4189 to your computer and use it in GitHub Desktop.
Save anonymous/1ff3d20de316fd6b3d4b4839bc6c4189 to your computer and use it in GitHub Desktop.
#include <vector>
#include <string>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <iomanip>
class student {
public:
std::string name;
int id;
};
struct exam_result {
public:
student* who;
tm when;
int mark;
};
int main() {
const unsigned count = 10;
std::vector<std::string>
names = { "Славик", "Ванька", "Митяй", "Глеб", "Данил" },
surnames = { "Сычёв", "Шеремет", "Бафомет", "Срака" };
std::vector<student> students(count);
std::generate(students.begin(), students.end(), [&] {
return student{
names[std::rand() % names.size()] + " "
+ surnames[std::rand() % surnames.size()],
std::rand()
};
});
auto read_info = [&] (student* s) {
tm d; int m;
std::cin >> std::get_time(&d, "%d.%m.%Y");
std::cin >> m;
return exam_result{
s, d, m
};
};
std::vector<exam_result> русиш(count), матеша(count);
for (int i = 0; i < count; ++i) {
i[русиш.data()] = read_info(&i[students.data()]);
i[матеша.data()] = read_info(&i[students.data()]);
}
for (int i = 0; i < count; ++i) {
if (i[русиш.data()].mark > 2 || i[матеша.data()].mark > 2)
continue;
std::cout << i[русиш.data()].who->name << " is a loser!"
<< std::endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment