semkaegor4ik

бинарные файлы

Apr 9th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. using namespace std;
  5. int main()
  6. {
  7.     ofstream out("chetni.txt", ios::binary);
  8.     int n;
  9.     int k = 0;
  10.     cin >> n;
  11.     for (int i = 0; i <= n; i++)
  12.     {
  13.         k = i;
  14.         out.write((char*)& k, sizeof(double));
  15.     }
  16.     out.close();
  17.     ifstream in("chetni.txt", ios::binary);
  18.     while (in.peek() != EOF)
  19.     {
  20.         in.read((char*)& k, sizeof(double));
  21.         if((k%2==0)&&(k!=0))
  22.             cout << k << ' ';
  23.         in.seekg(sizeof(double), ios::cur);
  24.     }
  25.     in.close();
  26.     return 0;
  27. }
Add Comment
Please, Sign In to add comment