if (gepakteLucifers == 1) {
printf("De computer pakt 3 lucifers\n");
printf("%d - %d = %d\n\n", lucifers, 3, lucifers - 3);
lucifers = lucifers - 3;
}
if (gepakteLucifers == 2) {
printf("De computer pakt 2 lucifers\n");
printf("%d - %d = %d\n\n", lucifers, 2, lucifers - 2);
lucifers = lucifers - 2;
}
if (gepakteLucifers == 3) {
printf("De computer pakt 1 lucifer\n");
printf("%d - %d = %d\n\n", lucifers, 1, lucifers - 1);
lucifers = lucifers - 1;
}
There are too many if statements. It needs to be simplified but I don't know how.
edit : this is for nim game so when the player picks 3 the computer has to pick 1, if the player picks 2 the computer has to pick 2, if the player picks 3 the computer has to pick 1. And that's it.