geekbrains_cpp_difficult_mo.../lesson_7/exercise_3.cpp

39 lines
781 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* exercise_3.cpp
*
* Created on: 15 окт. 2021 г.
* Author: alexander
*/
#include "exercise_3.hpp"
#include <numeric>
void exercise_3()
{
exercise_2::FullName fn;
fn.set_name("Alexander");
fn.set_surname("Zhirov");
fn.set_patronymic("Alexandrovich");
exercise_2::Student s;
*s.mutable_name() = fn;
s.add_grades(5);
s.add_grades(2);
s.add_grades(4);
s.add_grades(3);
s.add_grades(4);
s.add_grades(3);
s.add_grades(4);
s.add_grades(3);
s.set_avg_score(std::accumulate(s.grades().begin(), s.grades().end(), 0) / s.grades().size());
SG::StudentsGroup sg;
sg.add_student(s);
sg.Save();
SG::StudentsGroup new_sg;
new_sg.Open();
std:: cout << new_sg.GetAllInfo(fn) << std::endl;
}