Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define N 10
- inline int toInt(char ch) {
- return ch - 'a';
- }
- int fr[3] = { 3, 4, 3 };
- char s[N];
- int cnt = 0;
- void bktr(int k) {
- if (k == N) {
- for (int i = 0; i < N; i++) {
- printf("%c", s[i]);
- }
- puts("");
- cnt++;
- if (cnt == 5) {
- exit(EXIT_SUCCESS);
- }
- return;
- }
- for (char ch = 'a'; ch <= 'c'; ch++) {
- if (fr[toInt(ch)] != 0) {
- fr[toInt(ch)]--;
- s[k] = ch;
- bktr(k + 1);
- fr[toInt(ch)]++;
- }
- }
- }
- int main(void) {
- bktr(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement