Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- const int WordLength = 21;
- const int SurnameLength = 16;
- const int NumberStudent = 15;
- const int NumberExams = 9;
- struct date
- {
- int Day;
- int Month;
- int Year;
- };
- struct student
- {
- char Surname[WordLength];
- int Points;
- };
- struct exam
- {
- int GroupNumber;
- char SubjectName[WordLength];
- char Surname[SurnameLength];
- date Date;
- student Students[15];
- };
- void A(string filename)
- {
- exam Exam;
- ifstream fin(filename, ios::binary);
- int count = 0;
- for (int i = 0; i < NumberExams; i++)
- {
- fin.read((char*)&Exam, sizeof(exam));
- if (strcmp(Exam.SubjectName, "Информатика") == 0)
- {
- bool t = true;
- for (int i = 0; i < NumberStudent && t; i++)
- {
- if (Exam.Students[i].Points < 71) // Успешно >=71
- {
- t = false;
- }
- }
- if (t)
- count++;
- }
- }
- cout << "Количество групп " << count;
- cout << endl << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- ifstream fin("input.txt");
- if (!fin.is_open())
- {
- cout << "Файл не найден ";
- }
- else
- {
- ofstream fout("input.bin", ios::binary);
- while (fin.peek() != EOF)
- {
- exam Exam;
- fin >> Exam.GroupNumber;
- fin >> Exam.SubjectName;
- fin >> Exam.Surname;
- string str;
- fin >> str;
- int chislo = 0;
- for (int i = 0; i < str.size(); i++)
- {
- if (str[i] != '.')
- {
- chislo = chislo * 10 + str[i] - '0';
- }
- if (i == 3)
- {
- Exam.Date.Day = chislo;
- chislo = 0;
- }
- if (i == 6)
- {
- Exam.Date.Month = chislo;
- chislo = 0;
- }
- if (i == 8)
- {
- Exam.Date.Year = chislo;
- }
- }
- for (int i = 0; i < 15; i++)
- {
- fin >> Exam.Students[i].Surname;
- fin >> Exam.Students[i].Points;
- }
- fout.write((char*)&Exam, sizeof(exam));
- }
- fin.close();
- fout.close();
- cout.setf(ios::left);
- A("input.bin");
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement