题解 P1157 【组合的输出】


啦啦啦,最简单的电风扇(dfs)(居然有大佬说不能用递归?!)

懒得写BFS,太繁琐了。

程序不喜勿喷

#include
using namespace std;
int f[100];//数组484开大了点(记录输出序列)
bool bz[100];//记录是否取过
int n,r;
void dfs(int l,int now)
{
	if(l==r) //如果搜完
	{
		for(int i=1;i<=l;i++) printf("%3d",f[i]);//格式输出
		cout<>n>>r;
	dfs(0,0);//简短的主程序~QwQ
	return 0;
}

Byebye~