Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- struct abit
- {
- char fio[40];
- int mark[3];
- int summ;
- };
- int main()
- {
- setlocale(LC_ALL, "ru");
- ifstream in("arb.txt");
- ofstream outbin("abit.bin", ios::binary);
- if (!in)
- {
- cout << "file not found" << endl;
- system("pause");
- exit(-1);
- }
- abit x;
- while (in >> x.fio >> x.mark[0] >> x.mark[1] >> x.mark[2])
- {
- if ((x.mark[0] >= 40) && (x.mark[1] >= 40) && (x.mark[2] >= 40))
- {
- x.summ = x.mark[0] + x.mark[1] + x.mark[2];
- outbin.write((char*)&x, sizeof(struct abit));
- }
- }
- in.close();
- outbin.close();
- ifstream inbin("abit.bin", ios::binary);
- if (!inbin)
- {
- cout << "file not found" << endl;
- system("pause");
- exit(-1);
- }
- cout << "Абитуриенты, подавшие заявления и прошедшие на конкурс:" << endl;
- while (inbin.read((char*)&x, sizeof(struct abit)))
- {
- cout << x.fio << setw(6) << x.summ << endl;
- }
- inbin.close();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement