Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ///****************
- string create() {
- string alfa = "";
- for (char c = 'a'; c <= 'z'; c++)
- alfa += c;
- return alfa;
- }
- const string alfa = create();
- int n, k;
- string st;
- void bktr(int top) {
- if (n == top) {
- puts(st.c_str());
- return;
- }
- for (int i = 0; i < k; i++) {
- st[top] = alfa[i];
- bktr(top + 1);
- }
- }
- int main() {
- cin >> n >> k;
- assert(k >= 1 && k <= alfa.size());
- st.resize(n + 3);
- bktr(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement