realpython / realpython/materials

проект2

Open
#725 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
5.2k
Forks
5.3k
Avg merge
4d 10h
Merged PRs (30d)
10

Description

грамотно ли написан следующий код:
#include
#include
#include
#include

using namespace std;

struct Student {
string name;
vector grades;
};

// Функция для определения успеваемости
string determinePerformance(const vector& grades) {
bool hasFive = false;
bool hasFour = false;
bool hasThree = false;
bool hasTwo = false;

for (int grade : grades) {
    if (grade == 5) hasFive = true;
    if (grade == 4) hasFour = true;
    if (grade == 3) hasThree = true;
    if (grade == 2) hasTwo = true;
}

if (hasTwo) return "Угроза отчисления";
if (hasThree) return "Надо стараться лучше";
if (hasFive && !hasFour) return "Молодец";
if (hasFive && hasFour) return "Хорошо";
if (hasFour && !hasFive) return "Неплохо";
return "У вас есть стипендия";

}

// Функция для вычисления среднего балла
double calculateAverage(const vector& grades) {
double sum = 0;
for (int grade : grades) {
sum += grade;
}
return sum / grades.size();
}

int main() {
// Данные студентов
vector students = {
{"Иванов Иван", {5, 5, 5, 4}},
{"Максимов Максим", {4, 3, 4, 4}},
{"Андреевич Андрей", {3, 3, 5, 5}}
};

// Вывод информации о каждом студенте
for (const auto& student : students) {
    cout << "Имя: " << student.name << endl;
    cout << "Оценки: ";
    for (int grade : student.grades) {
        cout << grade << " ";
    }
    cout << endl;
    cout << "Средний балл: " << calculateAverage(student.grades) << endl;
    cout << "Успеваемость: " << determinePerformance(student.grades) << endl;
}

return 0;

}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the pasted C++ program and determine whether it belongs in this repository's educational materials. No project file, test, or specific correction is identified, so the issue needs a defined target and acceptance criteria before work can be considered done.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
content
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.