#include int main() { int answer[4] = {1, 6, 2, 6}; int guess[4]; int answer_matched[4], guess_matched[4]; int trial=0, black, white; int i, j; do { trial++; black = 0; white = 0; for (i=0; i<4; i++) { answer_matched[i] = 0; guess_matched[i] = 0; } printf("Trial %d: ", trial); for (i=0; i<4; i++) scanf("%d", &guess[i]); for (i=0; i<4; i++) if (answer[i] == guess[i]) { answer_matched[i] = 1; guess_matched[i] = 1; black++; } for (i=0; i<4; i++) for (j=0; j<4; j++) if ((answer_matched[i] == 0) && (guess_matched[j] == 0) && (answer[i] == guess[j])) { answer_matched[i] = 1; guess_matched[j] = 1; white++; } printf("%d Black, %d White\n\n", black, white); } while ((trial < 6) && (black < 4)); printf("The answer is "); for (i=0; i<4; i++) printf("%d ", answer[i]); printf("\n\n"); if (black == 4) printf("Congratulation! You win the game.\n"); else printf("You lose the game\n"); return 0; }