Advertisement
Seal_of_approval

2p57

Dec 16th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int main (void)
  5. {
  6. ifstream inp("input.txt");
  7. ofstream out("fail.dat",ios::binary);
  8. int n,c;
  9. cout << "Enter your numbers ";
  10. cin >> n;
  11. for (int i = 0; i < n; i++)
  12. {
  13. inp >> c;
  14. out.write((char*)&c, sizeof(int));
  15. }
  16. out.close();
  17. ifstream in("fail.dat",ios::binary);
  18. int a,b;
  19. cout << "Enter a and b ";
  20. cin >> a >> b;
  21. while (in.peek()!= EOF)
  22. {
  23. in.read((char*)&c, sizeof(int));
  24. if (c >= a && c <=b)
  25. cout << c << " ";
  26. }
  27. in.close();
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement