#include #include using namespace std; int main(){ int n,k; cout << "Enter N and K? "; cin >> n >> k; for(int i = 0; i < (2 << (n-1)); ++i){ queueq; for (int j = 0; j < n; ++j){ if (((i >> j) & 1) == 1){ //its gonna be used q.push(j+1); if (q.size() > k){ break; } } } if (q.size() == k){ cout << q.front(); q.pop(); while(!q.empty()){ cout << " " << q.front(); q.pop(); } cout << "\n"; } } }