Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- #include "conio.h"
- using namespace std;
- const int people = 3;
- const int subjects = 3;
- struct T_date
- {
- unsigned day;
- unsigned month;
- unsigned year;
- };
- struct T_subject
- {
- char name[40];
- int unsigned mark;
- };
- struct T_student
- {
- char fio[40];
- T_date birthday;
- T_subject certificate[subjects];
- };
- T_student add_struct(int i)
- {
- T_student a;
- char c;
- cout << endl << "Enter data " << i+1 << " person\n";
- cout << " fio ";
- cin.getline(a.fio,40);
- cout << endl << "Enter date of birthday: \n";
- cout <<" day (1-31) ";
- cin >> a.birthday.day;
- cin.get(c);
- cout << " month (1-12) ";
- cin >> a.birthday.month;
- cin.get(c);
- cout << " year (YYYY) ";
- cin >> a.birthday.year;
- cin.get(c);
- cout << endl << "List of subjects: Math, Phys, Rus, etc" << endl;
- for(int i = 0; i < subjects; i++)
- {
- cout << "\nEnter " << i+1 << " subject name: ";
- cin.getline(a.certificate[i].name,40);
- cout << " subject mark: ";
- cin >> a.certificate[i].mark;
- cin.get(c);
- }
- return a;
- };
- void write_table(T_student a)
- {
- printf("%15s ! %2d %2d %4d ", a.fio, a.birthday.day, a.birthday.month, a.birthday.year);
- for(int i = 0; i < subjects; i++)
- printf("! %4s ! %1d ", a.certificate[i].name, a.certificate[i].mark);
- printf("\n");
- }
- void write_result_table(T_student a)
- {
- bool math_true = false, phys_true = false;
- for(int i = 0; i < subjects; i++)
- {
- if (strcmp(a.certificate[i].name, "Math") == 0 && a.certificate[i].mark > 3)
- math_true = true;
- if (strcmp(a.certificate[i].name, "Phys") == 0 && a.certificate[i].mark > 3)
- phys_true = true;
- }
- if(phys_true && math_true)
- printf("%15s ! %1d ! %1d\n", a.fio, a.certificate[0].mark, a.certificate[1].mark);
- }
- int main()
- {
- cout << " Avtor – Klipikov A. V., student gr. PIbd-11" << endl;
- cout << " Variant N 21" << endl;
- cout << " Programma sozdaet massiv structur, zapolnaet ego dannimi i vivodit na ekran etot massiv v vide tablici" << endl;
- cout << " Programma vivodit massiv abiturientov, imeuschih po matematike i fizike ne nizhe 4, v vide tablici" << endl << endl;
- T_student list[people] = {"Klipikov A. V.", 29, 5, 1995, "Math", 4, "Phys", 5, "Rus", 5,
- "Ivanov I.I.", 1, 1, 1995, "Math", 3, "Phys", 3, "Rus", 3};
- for(int i = 2; i < people; i++)
- {
- list[i] = add_struct(i);
- }
- cout << "-----------------------------";
- for(int i = 0; i < subjects; i++)
- cout << "--------------";
- cout << endl << " ! ! certificate";
- cout << endl << " fio ! birthday ";
- for(int i = 0; i < subjects; i++)
- cout << "--------------";
- cout << endl << " ! ";
- for(int i = 0; i < subjects; i++)
- cout << "! name ! mark ";
- cout << endl << "-----------------------------";
- for(int i = 0; i < subjects; i++)
- cout << "--------------";
- cout << endl;
- for(int i = 0; i < people; i++)
- {
- write_table(list[i]);
- }
- cout << endl << endl;
- cout << "---------------------------------------" << endl;
- cout << " fio ! Math ! Phys !" << endl;
- cout << "---------------------------------------" << endl;
- for(int i = 0; i < people; i++)
- {
- write_result_table(list[i]);
- }
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement