Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define N_COLS 6
- const char* COLORS[] = {"white", "yellow", "red", "green", "blue", "black"};
- #define N 3
- int flag[N];
- void printFlag() {
- for (int i = 0; i < N; i++) {
- printf("%s ", COLORS[flag[i]]);
- }
- putchar('\n');
- }
- void bktr(int k) {
- if (k == N) {//sol
- if (flag[0] == flag[1] || flag[1] == flag[2] || flag[0] == flag[2]) {
- return;
- }
- printFlag();
- return;
- }
- if (k == 1) {
- flag[k] = 1;
- bktr(k + 1);
- flag[k] = 3;
- bktr(k + 1);
- return;
- }//*/
- for (int i = 0; i < N_COLS; i++) {
- flag[k] = i;
- bktr(k + 1);
- }
- }
- int main(void) {
- bktr(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement