Skip to content

Instantly share code, notes, and snippets.

@bilinin
Last active February 28, 2017 17:22
Show Gist options
  • Save bilinin/76f525b1459f1f77dac58614b2d3badf to your computer and use it in GitHub Desktop.
Save bilinin/76f525b1459f1f77dac58614b2d3badf to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
using namespace std;
struct Mmarks{
int algebra;
int geometria;
int chemistry;
};
class Abiturient{
public:
// Конструктор
Abiturient(string FirstName, string LastName, string MiddleName, string Adress, Mmarks Marks){
set_first_name(FirstName);
set_last_name(LastName);
set_middle_name(MiddleName);
set_adress(Adress);
set_marks(Marks);
}
// Сеттеры
void set_first_name(string first_name){
FirstName = first_name;
}
void set_last_name(string last_name){
LastName = last_name;
}
void set_middle_name(string middle_name){
MiddleName = middle_name;
}
void set_adress(string adress){
Adress = adress ;
}
void set_marks(Mmarks marks){
Marks = marks ;
}
// Геттеры
string get_first_name(){
return FirstName;
}
string get_last_name(){
return LastName;
}
string get_middle_name(){
return MiddleName;
}
string get_adress(){
return Adress;
}
Mmarks get_marks(){
return Marks;
}
// other
void print_all_data(){
cout << FirstName << " " << LastName << " " << MiddleName << " "
<< " " << Adress<< " marks : " << Marks.algebra<<" " << Marks.chemistry<<" " << Marks.geometria<< endl;
}
private:
string FirstName,
LastName,
MiddleName,
Adress;
Mmarks Marks;
};
void search_bad(vector <Abiturient> Abiturients){
cout << "\n\nWith bad marks " << endl;
int size = Abiturients.size();
for (int i = 0;i<size; i++){
Mmarks current_marks = Abiturients[i].get_marks();
if((current_marks.geometria < 4) || (current_marks.chemistry < 4) || (current_marks.algebra < 4)) {
Abiturients[i].print_all_data();
}
}
}
void search_summ_less(vector <Abiturient> Abiturients, int summ){
cout << "\n\nSumm less then " << summ << endl;
int size = Abiturients.size();
for (int i = 0;i<size; i++){
Mmarks current_marks = Abiturients[i].get_marks();
if((current_marks.geometria + current_marks.chemistry + current_marks.geometria) < summ) {
Abiturients[i].print_all_data();
}
}
}
int main() {
vector <Abiturient> Abiturients;
Abiturients.push_back(Abiturient("Ivan","Ivanov","Ivanovich","Kropotkina 10",{5,5,5}));
Abiturients.push_back(Abiturient("Petr","Petrov","Petrovich","Kropotkina 20",{4,4,4}));
Abiturients.push_back(Abiturient("Andrey","Pushkin","Ivanovich","Kropotkina 21",{3,5,4}));
Abiturients.push_back(Abiturient("Oleg","Kalinin","Vladimirovich","Titova 23",{5,4,5}));
Abiturients.push_back(Abiturient("Regina","Makarova","Daniilovna","Titova 23",{3,5,5}));
Abiturients.push_back(Abiturient("Evgeny","Abramov","Pavlovich","Dekabristov 7",{3,5,3}));
Abiturients.push_back(Abiturient("Vladimir","Maksimov","Andreevich","Lenina 5",{3,3,3}));
Abiturients.push_back(Abiturient("Oksna","Muhina","Artemovna","Bogatkova 63",{5,5,5}));
search_bad(Abiturients);
search_summ_less(Abiturients, 12);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment