模拟二进制加法

Posted xxxsans

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了模拟二进制加法相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>
using namespace std;
void dfs( int index , int a[] , int n ){
    
    if( index == n ){
        for( int i = 0 ; i < n ; i ++ )
            cout << a[i];
        cout << endl;
        return;
    }
    
    for( int i = 0 ; i < 2 ; i ++ ){
        a[index] = i;
        dfs( index+1,a,n );
    }
}
int main()
{
    int n;
    cin >> n;
    int a[10];
    dfs(0,a,n);
    return 0;
}

 

以上是关于模拟二进制加法的主要内容,如果未能解决你的问题,请参考以下文章