提交时间:2024-03-26 13:47:51

运行 ID: 139855

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