52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/*
|
||
* main.cpp
|
||
*
|
||
* Created on: 14 окт. 2021 г.
|
||
* Author: alexander
|
||
*/
|
||
|
||
#include <iostream>
|
||
#include <numeric>
|
||
#include <fstream>
|
||
#include "src-gen/exercise_2.pb.h"
|
||
|
||
int main()
|
||
{
|
||
// exercise_2::FullName fn;
|
||
// fn.set_name("Alexander");
|
||
// fn.set_surname("Zhirov");
|
||
// fn.set_patronymic("Alexandrovich");
|
||
//
|
||
// exercise_2::Student s;
|
||
// s.set_allocated_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());
|
||
//
|
||
// exercise_2::StudentsGroup sg;
|
||
// *sg.add_students() = s;
|
||
//
|
||
// std::ofstream out("student.bin", std::ios_base::binary);
|
||
// sg.SerializeToOstream(&out);
|
||
|
||
exercise_2::StudentsGroup sg;
|
||
std::ifstream in("student.bin", std::ios_base::binary);
|
||
if (sg.ParseFromIstream(&in))
|
||
{
|
||
std::cout << sg.students(0).name().surname() << std::endl;
|
||
std::cout << sg.students(0).avg_score() << std::endl;
|
||
}
|
||
else
|
||
{
|
||
std::cout << "Error!" << std::endl;
|
||
}
|
||
|
||
return 0;
|
||
}
|