#include <iostream> #include <cmath> #include <stack> using namespace std; int N,M; //#balls, #draw int main () { cin >> N >> M; int size=(int)pow((float)N,(float)M); for (int i=0;i<size;i++){ int a=i; stack<int> s; for (int j=0;j<M;j++){ s.push(a%N); a = a/N; } while(!s.empty()){ cout << s.top() << ' '; s.pop(); } cout << endl; } }
3 2
0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2
沒有留言:
張貼留言