Bob103

BEst!

May 4th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. ofstream fout("in.dat", ios_base::binary);
  9. int i, n;
  10. do
  11. {
  12. cout << "Enter N: ";
  13. cin >> n;
  14. } while (n <= 0);
  15. cout << "Enter " << n << " number\n";
  16. int m;
  17. for (i = 0; i < n; i++)
  18. {
  19. cout << "Enter number ";
  20. cin >> m;
  21. fout.write((char*)&m, sizeof m);
  22. }
  23. fout.close();
  24. ifstream fin("in.dat", ios_base::binary);
  25. int minus;
  26. while (!fin.eof())
  27. {
  28. fin.read((char*)&m, sizeof m);
  29. if (m < 0)
  30. cout << m << " ";
  31. }
  32. fin.close();
  33. system("pause");
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment