fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4.  
  5. bool increase(std::vector<bool>& v)
  6. {
  7. for (std::size_t i = 0; i != v.size(); ++i) {
  8. v[i] = !v[i];
  9. if (v[i] == true) {
  10. return true;
  11. }
  12. }
  13. return false;
  14. }
  15.  
  16. int main()
  17. {
  18. std::vector<bool> v(5);
  19.  
  20. do {
  21. for (std::size_t i = 0; i != v.size(); ++i) {
  22. std::cout << v[i] << " ";
  23. }
  24. std::cout << std::endl;
  25. } while (increase(v));
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
0 0 0 0 0 
1 0 0 0 0 
0 1 0 0 0 
1 1 0 0 0 
0 0 1 0 0 
1 0 1 0 0 
0 1 1 0 0 
1 1 1 0 0 
0 0 0 1 0 
1 0 0 1 0 
0 1 0 1 0 
1 1 0 1 0 
0 0 1 1 0 
1 0 1 1 0 
0 1 1 1 0 
1 1 1 1 0 
0 0 0 0 1 
1 0 0 0 1 
0 1 0 0 1 
1 1 0 0 1 
0 0 1 0 1 
1 0 1 0 1 
0 1 1 0 1 
1 1 1 0 1 
0 0 0 1 1 
1 0 0 1 1 
0 1 0 1 1 
1 1 0 1 1 
0 0 1 1 1 
1 0 1 1 1 
0 1 1 1 1 
1 1 1 1 1