Advertisement
JouJoy

Untitled

Mar 4th, 2020
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <fstream>
  4. using namespace std;
  5. struct abit
  6. {
  7.     char fio[40];
  8.     int mark[3];
  9.     int summ;
  10. };
  11. int main()
  12. {
  13.     setlocale(LC_ALL, "ru");
  14.     ifstream in("arb.txt");
  15.     ofstream outbin("abit.bin", ios::binary);
  16.     if (!in)
  17.     {
  18.         cout << "file not found" << endl;
  19.         system("pause");
  20.         exit(-1);
  21.     }
  22.     abit x;
  23.     while (in >> x.fio >> x.mark[0] >> x.mark[1] >> x.mark[2])
  24.     {
  25.         if ((x.mark[0] >= 40) && (x.mark[1] >= 40) && (x.mark[2] >= 40))
  26.         {
  27.             x.summ = x.mark[0] + x.mark[1] + x.mark[2];
  28.             outbin.write((char*)&x, sizeof(struct abit));
  29.         }
  30.     }
  31.     in.close();
  32.     outbin.close();
  33.     ifstream inbin("abit.bin", ios::binary);
  34.         if (!inbin)
  35.         {
  36.             cout << "file not found" << endl;
  37.             system("pause");
  38.             exit(-1);
  39.         }
  40.         cout << "Абитуриенты, подавшие заявления и прошедшие на конкурс:" << endl;
  41.         while (inbin.read((char*)&x, sizeof(struct abit)))
  42.         {
  43.             cout << x.fio << setw(6) << x.summ << endl;
  44.         }
  45.         inbin.close();
  46.         system("pause");
  47.         return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement