Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- class Football {
- public:
- Football() :
- game_(0), win_(0), draw_(0), losing_(0), gs_(0), gc_(0) {}
- explicit Football(string& name) :
- name_(name), game_(0), win_(0), draw_(0), losing_(0), gs_(0),gc_(0) {}
- void win(unsigned value) {
- win_ = value;
- game_ += value;
- }
- void draw(unsigned value) {
- draw_ = value;
- game_ += value;
- }
- void losing(unsigned value) {
- losing_ = value;
- game_ += value;
- }
- void goals_scored(unsigned value) {
- gs_ = value;
- }
- void goals_conceded(unsigned value) {
- gc_ = value;
- }
- unsigned points_scored()const {
- return win_ * 3 + draw_;
- }
- private:
- string name_;
- unsigned game_;
- unsigned win_;
- unsigned draw_;
- unsigned losing_;
- unsigned gs_;
- unsigned gc_;
- friend ostream& operator<<(ostream& out, const Football& fb) {
- out << left << setw(24) << fb.name_ << right
- << setw(5) << fb.game_
- << setw(5) << fb.win_
- << setw(5) << fb.draw_
- << setw(5) << fb.losing_
- << setw(5) << fb.gs_
- << " - " << setw(2) << fb.gc_
- << setw(5) << fb.points_scored();
- return out;
- }
- friend bool operator>(const Football& a, const Football& b) {
- return a.points_scored() > b.points_scored();
- }
- };
- unsigned input(const char* msg) {
- cout << msg;
- unsigned value;
- cin >> value;
- cin.ignore(numeric_limits<streamsize>::max(), '\n');
- return value;
- }
- Football team() {
- cout << "Название команды: ";
- string name;
- getline(cin, name);
- Football club(name);
- club.win(input("Количество побед: "));
- club.draw(input("Количество ничьих: "));
- club.losing(input("Количество поражений: "));
- club.goals_scored(input("Количество забитых мячей: "));
- club.goals_conceded(input("Количество пропущенных мячей: "));
- return club;
- }
- void title() {
- cout << "\n"
- << setw(15) << "Команда"
- << setw(14) << "И"
- << setw(5) << "В"
- << setw(5) << "Н"
- << setw(5) << "П"
- << setw(9) << "З - П"
- << setw(8) << "О\n\n";
- }
- int main() {
- system("chcp 1251 > nul");
- Football table[8];
- for (auto& club : table) club = team();
- sort(begin(table), end(table), greater<Football>());
- system("cls");
- title();
- for (const auto& club : table) cout << club << '\n';
- system("pause > nul");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement