#include <bits/stdc++.h>
using namespace std;
//14888 ㄱㄱ

int n,m;
int arr[10];
void NM(int now_n){
    if(now_n==m) {
        for(int i=0;i<m; i++) {
            cout << arr[i] << ' ';
        }
        cout << '\n';
        return;
    }
    for(int i=1; i<=n; i++) {
        arr[now_n]=i;
        NM(now_n+1);
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    NM(0);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: