提交时间:2024-03-09 15:08:51

运行 ID: 136777

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