蒟蒻求求大佬67分qwq
查看原帖
蒟蒻求求大佬67分qwq
788995
Blanchard楼主2024/3/5 19:33
#include<bits/stdc++.h>
using namespace std;
int a[101];
int st[101] = { 0 };
int n, m;
void dfs(int step, int m)
{
	if (step>m)
	{
		for (int i = 1; i <= m; i++)
		{
			cout << a[i] << " ";
		}
		cout << endl;
		return;
	}
	for (int i = 1; i <= m; i++)
	{
		if (st[i] == 0)
		{
			a[step] = i;
			st[i] = 1;
			dfs(step + 1, n);
			st[i] = 0;
		}
	}
	return;
}
int main() {
	cin >> n >> m;
	dfs(1, m);
	return 0;
}
2024/3/5 19:33
加载中...