Untitled

 avatar
unknown
plain_text
5 months ago
2.0 kB
2
Indexable
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

class Student {
private:
    std::string nume;
    std::string prenume;
    std::vector<int> note;

    double calcMedie() {
        double suma = 0;
        for (int nota : note) {
            suma += nota;
        }
        return suma / note.size();
    }

    bool esteIntegralist() {
        for (int nota : note) {
            if (nota < 5) {
                return false;
            }
        }
        return true;
    }

public:
    Student(const std::string& nume, const std::string& prenume, const std::vector<int>& note)
            : nume(nume), prenume(prenume), note(note) {}

    int areBursaMerit() {
        if (esteIntegralist()) {
            double medie = calcMedie();
            if (medie >= 8 && medie < 9.80) {
                return 1; // bursă de merit
            }
        }
        return 0;
    }

    int areBursaPerformanta() {
        if (esteIntegralist()) {
            double medie = calcMedie();
            if (medie >= 9.80) {
                return 1; // bursă de performanță
            }
        }
        return 0;
    }
};

int main() {
    int n;
    std::cin >> n;
    std::cin.ignore(); // pentru a ignora newline-ul rămas după citirea lui n

    int bursieriMerit = 0;
    int bursieriPerformanta = 0;

    for (int i = 0; i < n; ++i) {
        std::string linie;
        std::getline(std::cin, linie);
        std::istringstream iss(linie);

        std::string nume, prenume;
        int nota;
        std::vector<int> note;

        iss >> nume >> prenume;
        for (int j = 0; j < 5; ++j) {
            iss >> nota;
            note.push_back(nota);
        }

        Student student(nume, prenume, note);
        bursieriMerit += student.areBursaMerit();
        bursieriPerformanta += student.areBursaPerformanta();
    }

    std::cout << bursieriMerit << " " << bursieriPerformanta << std::endl;

    return 0;
}
Editor is loading...
Leave a Comment