Advertisement
nguyenvanquan7826

dãy nhị phân quay lui

Feb 25th, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. /*
  2.  * nhiphan.cpp
  3.  *
  4.  * Copyright 2014 by nguyenvanquan7826
  5.  *
  6.  * Email : [email protected]
  7.  * Blog : nguyenvanquan7826.wordpress.com
  8.  *
  9.  */
  10.  
  11. #include <iostream>
  12. #define N 3
  13. using namespace std;
  14.  
  15. int a[N];
  16. void quaylui(int i){
  17.     for (int j = 0; j < 2; j++){
  18.         a[i] = j;
  19.         if (i < N){
  20.             if (i == N - 1){
  21.                 for (int k = 0; k < N; k++)
  22.                     cout << a[k];
  23.                 cout << endl;
  24.             }
  25.             else quaylui(i+1);
  26.         }
  27.     }
  28. }
  29.  
  30. int main (int argc, char **argv)
  31. {
  32.     quaylui(0);
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement