Question: Bulls and Cows Part 2: The code and guess must each be stored in an array of ints. You may not use vectors. Follow formatting

Bulls and Cows Part 2:

  • The code and guess must each be stored in an array of ints.

  • You may not use vectors.

  • Follow formatting as demonstrated in the "Sample Runs" below.

  • You may not use string comparisons.

  • Even though we only have require the program to work with codes of 3, 4 or 5 digits, your program should be easy to modify and scale to 2 - 9 digits.

  • Do not use functions to find something that you could do by iterating through the array yourself. E.g. Do not use something like .find() instead of practicing iterating through a compound data structure (i.e. array) element by element and determining if there is a match during the iteration.

Sample Runs

Enter number of digits in code (3, 4 or 5): 0 Enter code: 2894 Enter number of digits in code: 4 Number to guess: 2-8-9-4 Enter Guess: 5555 Each number must be different. Enter Guess: 59 Each number must be different. Enter Guess: 12345 You can only enter 4 digits. Enter Guess: 112233 You can only enter 4 digits. Enter Guess: 4698 1 bulls 2 cows Enter Guess: 9687 0 bulls 2 cows Enter Guess: 2894 4 bulls... 2-8-9-4 is correct!

Enter number of digits in code (3, 4 or 5): 0 Enter code: 29 Enter number of digits in code: 3 Number to guess: 0-2-9 Enter Guess: 89 2 bulls 0 cows Enter Guess: 29 3 bulls... 0-2-9 is correct!

Please if possible make the output as close to the sample run as possible. Thank you SO much for your time!!!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!