문제 링크 - https://www.acmicpc.net/problem/15651
[문제]

[풀이]
- N과 M(1) 문제에서 달라진 점은 수열을 만들때, 중복을 허용한다는 점이다. 그러므로 더이상 check[10]을 통해 수의 사용여부를 체크 할 필요 없이 바로 arr[]에 넣어주고, 다음 재귀함수로 넘어가면 된다.
- 자세한 풀이는 N과 M(1) 문제 풀이 참고.
[코드]
#include <iostream>
using namespace std;
bool check[10];
int arr[10];
void func(int index, int n, int m){
if(index>m){
for(int i=1; i<=m; i++){
cout<<arr[i]<<" ";
}
cout<<"\n";
return;
}
for(int i=1; i<=n; i++){
arr[index]=i;
func(index+1,n,m);
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
func(1,n,m);
}