Advertisement
JoelSjogren

Untitled

Jun 29th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int n = 20;
  4. bool increment(bool* a) {
  5.     for (int i = 0; i < n; i++) {
  6.         a[i] = not a[i];
  7.         if (a[i]) return false;
  8.     }
  9.     return true;
  10. }
  11. void disp(bool* a) {
  12.     for (int i = 0; i < n; i++) cout << a[i];
  13.     cout << endl;
  14. }
  15. int main() {
  16.     bool list[n];
  17.     for (int i = 0; i < n; i++) list[i] = 0;
  18.     disp(list);
  19.     while (not increment(list)) disp(list);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement