Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <windows.h>
- #include <fstream>
- using namespace std;
- struct predm {
- char name[20];
- int mark;
- };
- struct session {
- int predm_co;
- predm p[10];
- };
- struct student {
- char fam[20];
- char im[20];
- char ot[20];
- int b_day;
- int b_month;
- int b_year;
- int year_apply;
- char kaf[20];
- char group[20];
- int zachetka;
- int sess_co;
- session s[10];
- };
- class input {
- public:
- // int count;
- // void in_count() { cout << "введите число студентов"; cin >> count; }
- char key;
- void switcher_in() {
- cout << " ---МЕНЮ---\n Введите k для ввода информации о студенте \n Для выхода введите e \n Для просмотра информации, которую вы ввели, нажмите r"<< endl;
- cin >> key;
- }
- };
- class f : public virtual input {
- public:
- FILE* ou;
- int s = 0;
- void f_in() {
- fopen_s(&ou, "flilk", "wb");
- struct student chel;
- for (; 1;) {
- cout << "\n вы собираетесь вводить ? Для продолжения выберите нужный вариант \n 1 - для продолжения ввода \n 0 - для выхода 1/0\n";
- cin >> s;
- if (!s) break;
- cout << "Введите имя, фамилию и отчество студента " << endl;
- cin >> chel.im >> chel.fam >> chel.ot;
- cout << "Введите дату рожедния студента, день, месяц и год " << endl;
- cin >> chel.b_day >> chel.b_month >> chel.b_year;
- cout << "Введите кафедру, номер груммы и номер зачётки студента " << endl;
- cin >> chel.kaf >> chel.group >> chel.zachetka;
- cout << "Введите количество СЕССИЙ, по которым вы хотите ввести информацию по данному студенту " << endl;
- cin >> chel.sess_co;
- for (int i = 0; i < chel.sess_co; i++) {
- cout << "Введите количество предметов в "<< chel.sess_co<< " сессии, по которым вы хотите ввести данные этой сессии " << endl;
- cin >> chel.s[i].predm_co;
- for (int j = 0; j < chel.s[i].predm_co; j++) {
- cout << "Введите название предмета, а затем оценку по нему" << endl;
- cin >> chel.s[i].p[j].name >> chel.s[i].p[j].mark;
- }
- }
- }
- cout << "Введёная вами информация сохраняется в файл";
- fwrite(&chel, sizeof(chel), 1, ou);
- fclose(ou);
- cout << "Введённая вами информация была успешно осхранена в файл";
- }
- };
- class read : public virtual f{
- public:
- void f_read() {
- struct student chel;
- fopen_s(&ou, "flilk", "rb");
- fread(&chel, sizeof(chel), 1, ou);
- while (!feof(ou)) {
- cout << " ФИО студента " << chel.im << " " << chel.fam << " " << chel.ot << endl;
- cout << " Дата рождения студента " << chel.b_day << " " << chel.b_month << " " << chel.b_year << endl;
- cout << " Кафедра, номер группы и зачётки " << chel.kaf << " " << chel.group << " " << chel.zachetka << endl;
- cout << " Количество ссесий " << chel.sess_co << endl;
- for (int i = 0; i < chel.sess_co; i++) {
- cout << " Количество предметов данной сессии " << endl;
- cout << chel.s[i].predm_co << endl;
- for (int j = 0; j < chel.s[i].predm_co; j++) {
- cout << "Название предмета и оценка" << endl;
- cout << chel.s[i].p[j].name <<" " << chel.s[i].p[j].mark << endl;
- }
- }
- fread(&chel, sizeof(chel), 1, ou);
- }
- }
- };
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- read func;
- func.switcher_in();
- while (func.key != 'e') {
- switch (func.key) {
- case 'k': {func.f_in(); break; }
- case 'r': func.f_read();
- }
- func.switcher_in();
- }
- //func.f_save();
- }
Advertisement
Add Comment
Please, Sign In to add comment