i have a loop to go through a linked list and pitch the nodes (players) in pairs (like players 1 and 2, 3 and 4, 5 and 6...) and the asks user to input the winner for each match.
here, temp is the amount of players there are, stage represents the stage they are in (can think of as wins), and playerNumber represents each players number as they are ID by their number. Currently, this code works for the first stage, where we go through each pair and ask for the winner, and the winners "int stage" attribute is incremented by one, however, when we have, lets say 8 players, we will end up with 4 rounds, where the final round displays the winner only, I cant get this code to loop for N amount of rounds where each time it is called upon, it only looks at the winners of last round.
cur = head; for (int i = 0; i < temp; i++) { while (cur != NULL) { printf("***************\n%dv%d\n", cur->playerNumber , cur->next->playerNumber); int winner; scanf("%d", &winner); if (winner == cur->playerNumber) { cur->stage++; } else { cur->next->stage++; } cur = cur->next->next; } }