Answer the question
In order to leave comments, you need to log in
How to create a number guessing program?
Hello. The bottom line is that when I was just getting acquainted with programming, my brother threw me an exe of a self-written program. He lost the source, and I want to recreate this program.
Its essence is as follows:
Three columns with random numbers are given. You guess one number and enter the number of the column in which it is located. Then three more columns appear, with the same numbers, but scattered differently. Again you select a column in which your number. And so again. And then the program guesses the number you guessed.
In general, I have no idea how to implement it. I know that this is an absolutely primitive console program, but I'm still learning :)
Give at least some clues: algorithm, code example, links. I will be grateful to everything.
Answer the question
In order to leave comments, you need to log in
You can do this trick from the beginning with the cards and from there reveal the algorithm.
No tricks and guessing, banal sorting by category. When I read the essence of this card trick, I already shed a tear.
The algorithm is something like this:
1. Find the repeated numbers in columns 1 and 2, write them into a separate array.
2. Find duplicate numbers between our array and 3rd column.
A snag may arise if in the end we get not one repeating number, but several, in which case the program cannot determine in any way which number was guessed, you can display all the numbers found. In order to have fewer such situations, you need to choose a larger range of random numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question