Advertisement
JouJoy

Untitled

Mar 4th, 2020
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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.     ifstream in("arb.txt");
  14.     ofstream outbin("abit.bin", ios::binary);
  15.     if (!in)
  16.     {
  17.         cout << "file not found" << endl;
  18.         system("pause");
  19.         exit(-1);
  20.     }
  21.     abit x;
  22.     while (in >> x.fio >> x.mark[0] >> x.mark[1] >> x.mark[2])
  23.     {
  24.         if ((x.mark[0] >= 40) && (x.mark[1] >= 40) && (x.mark[2] >= 40))
  25.         {
  26.             x.summ = x.mark[0] + x.mark[1] + x.mark[2];
  27.             outbin.write((char*)&x, sizeof(struct abit));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement