首页 > 其他分享 >Acwing 92

Acwing 92

时间:2023-02-06 17:23:05浏览次数:46  
标签:selection end int start 92 Acwing

回溯

#include <iostream>
using namespace std;
const int N = 16;
bool record[N];
void selection(int start, int end) {
    if(start>end){  //到达上届
        for(int i = 1;i <= end;i++){
            if(record[i]) cout<<i<<" ";
        }
        cout<<endl;
        return;
    }
    record[start] = true;   //选
    selection(start + 1,end);
    record[start] = false;  //不选
    selection(start + 1,end);
}
int main(){
    int n = 0;
    cin>>n;
    selection(1,n);
    return 0;
}

标签:selection,end,int,start,92,Acwing
From: https://www.cnblogs.com/poteitoutou/p/17096025.html

相关文章