Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Program to determine seed score */
- #include <stdio.h>
- #include <stdbool.h>
- int main (void) {
- int PlayerOneScore, PlayerTwoScore, RoundsPlayed, PlayerOneWins, PlayerTwoWins, MaxWins;
- bool Proceed;
- PlayerOneScore = PlayerTwoScore = 128;
- for (Proceed = false; Proceed == false;) {
- printf("Enter the number of rounds played: ");
- scanf("%i", &RoundsPlayed);
- if (RoundsPlayed < 3)
- printf("Rounds played must be three or more.\n\n");
- else if (RoundsPlayed % 2 == 0)
- printf("Rounds played cannot be even.\n\n");
- else
- Proceed = true;
- }
- if (RoundsPlayed == 3)
- MaxWins = 2;
- else
- MaxWins = 2 + (RoundsPlayed / 3);
- printf("Player 1's score is %i\n", PlayerOneScore);
- printf("Player 2's score is %i\n", PlayerTwoScore);
- for (Proceed = false; Proceed == false;) {
- printf("Best of %i rounds.\n", RoundsPlayed);
- printf ("Max wins = %i.\n", MaxWins);
- printf("Enter how many wins Player 1 has: ");
- scanf("%i", &PlayerOneWins);
- getchar();
- printf("Enter how many wins Player 2 has: ");
- scanf("%i", &PlayerTwoWins);
- getchar();
- if (PlayerOneWins < 0 || PlayerTwoWins < 0) {
- printf("Neither score can be less than zero. Please re-enter the score.\n\n");
- }
- else if ((PlayerOneWins + PlayerTwoWins) > RoundsPlayed) {
- printf("The sum of both scores is greater than the number of rounds played. Please re-enter the score.\n\n");
- }
- else if (PlayerOneWins > MaxWins || PlayerTwoWins > MaxWins) {
- printf("Neither score are greater than the maximum wins allowed in the match. Please re-enter the score.\n\n");
- }
- else if (PlayerOneWins == 0) {
- PlayerOneScore -= PlayerTwoWins;
- PlayerTwoScore += PlayerTwoWins;
- Proceed = true;
- }
- else if (PlayerTwoWins == 0) {
- PlayerOneScore += PlayerOneWins;
- PlayerTwoScore -= PlayerOneWins;
- Proceed = true;
- }
- else if (PlayerOneWins > PlayerTwoWins) {
- PlayerOneScore += (PlayerOneWins - PlayerTwoWins);
- PlayerTwoScore -= (PlayerOneWins - PlayerTwoWins);
- Proceed = true;
- }
- else {
- PlayerOneScore -= (PlayerTwoWins - PlayerOneWins);
- PlayerTwoScore += (PlayerTwoWins - PlayerOneWins);
- Proceed = true;
- }
- }
- printf("Player 1's score is %i\n", PlayerOneScore);
- printf("Player 2's score is %i\n", PlayerTwoScore);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement