Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <algorithm>
  4. using namespace std;
  5. bool within_limits(char c)
  6. {
  7. if(c >= '1' && c <= '4')
  8. return true;
  9. return false;
  10. }
  11. int main()
  12. {
  13. string s;
  14. ofstream outfile;
  15. outfile.open("generate.txt");
  16.  
  17. for(unsigned long long int i = 11111111; i <= 44444444; ++i)
  18. {
  19. s = to_string(i);
  20. if(!any_of(s.begin(), s.end(), [](char q){return !within_limits(q);
  21. }))
  22. {
  23. outfile << "a ";
  24. for(unsigned short int j = 0; j < 4; ++j)
  25. {
  26. outfile << s[j] << ' ';
  27. }
  28. outfile << "b ";
  29. for(unsigned short int j = 4; j < 8; ++j)
  30. {
  31. outfile << s[j] << ' ';
  32. }
  33. outfile << '\n';
  34. }
  35. }
  36.  
  37. outfile.close();
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement