0% found this document useful (0 votes)
4 views1 page

Endpractice

The document contains a C++ program that calculates and prints the average grades of students. It defines functions to compute the average grade, print student information, and filter grades by subject. The main function initializes a list of students and their grades, then displays their average and filtered grades for mathematics.

Uploaded by

aaulymabibulla15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Endpractice

The document contains a C++ program that calculates and prints the average grades of students. It defines functions to compute the average grade, print student information, and filter grades by subject. The main function initializes a list of students and their grades, then displays their average and filtered grades for mathematics.

Uploaded by

aaulymabibulla15
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <iostream>

#include <vector>
#include <string>

using namespace std;


int main() {
double srednigrade(const vector<int>& grades) {
int sum = 0;
for (int grade : grades) {
sum += grade;
return grades.empty() ? 0 :<double>(sum) / grades.size();
}
void printgrade(const string& name, const vector<int>& grades) {
double average = srednigrade(grades);
cout << "учащиеся: " << name << " оценки :";
for (int grade : grades ){
cout << grade << " ";
}
cout << "средний балл " << average << endl;
vector<int> filgrade(const vector<pair<string, int>>& srednigrade, const
string& subject) {
for (const auto& entry : srednigrade) {
if (entry.first == subject) {
filgrade.push_back(entry.second);
}
}
int main {
vector<pair<string, vector<int>>> students = {
{"Аяулым", {5, 4, 3, 5}},
{"Каракат", {3, 4, 4, 5}},
{"Алида", {5, 5, 5, 5}}
};
for (const auto& student : students) {
printstudeninf(student.first, student.second);
}
vector<pair<string, int>> srednigrade = {{"математика", 5}, {"физика", 4},
{"математика", 3}};
vector<int> filgrade = filgrade(srednigrade, "математика");

cout << "Оценки по математике: ";


for (int grade : filgrade) {
cout << grade << " ";
}
cout << endl;

return 0;

You might also like