Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void print_string(string &cur_string, int bits_count, const int k, vector<char> &alf) {
- if (bits_count == 0) {
- cout << cur_string << '\n';
- return;
- }
- for (int i = k - 1; i >= 0; --i) {
- cur_string.push_back(alf[i]);
- print_string(cur_string, bits_count - 1, k, alf);
- cur_string.pop_back();
- }
- }
- int main() {
- int n, k;
- cin >> n >> k;
- vector<char> alf = {};
- for (char i = char('a'); i <= char('z'); ++i){
- alf.push_back(i);
- }
- string s;
- print_string(s, n, k, alf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement