Advertisement
Tec4Gen

Untitled

Apr 12th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. using namespace std;
  4. ofstream back("bin.dat",ios::binary);
  5. void main() {
  6. unsigned size = sizeof(int);
  7. int x, n, a;
  8. cin >> n;
  9. for (int i = 0; i < n; i++) {
  10. cin >> x;
  11. back.write((char*)& x, size);
  12. }
  13. back.close();
  14. ifstream go_in("bin.dat", ios::binary);
  15. cin >> a;
  16. while (go_in.read((char*) &x, size)) {
  17. if (x % a == 0) {
  18. cout << x << " ";
  19. }
  20. }
  21. go_in.close();
  22. system("pause");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement