Advertisement
myloyo

9.3.12

Mar 2nd, 2023 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main() {
  5.     ofstream out("f.dat", ios::binary);
  6.     double a, x;
  7.     int n;
  8.     cin >> x;
  9.     cin >> n;
  10.     for (int i = 0; i < n; i++) {
  11.         cin >> a;
  12.         out.write((char*)&a, sizeof(a));
  13.     }
  14.     out.close();
  15.     ifstream in("f.dat", ios::binary);
  16.     in.seekg(sizeof(double));
  17.     while (in.peek() != EOF) {
  18.         in.read((char*)&a, sizeof(double));
  19.         if (a < x) {
  20.             cout << a << " ";
  21.         }
  22.         in.seekg(sizeof(double), ios::cur);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement