Does any one have the program for C++ that the computer guesses the number that the user has? Please e mail me the code if you got it.
Thanks
This is a discussion on Program question within the C++ Programming forums, part of the General Programming Boards category; Does any one have the program for C++ that the computer guesses the number that the user has? Please e ...
Does any one have the program for C++ that the computer guesses the number that the user has? Please e mail me the code if you got it.
Thanks
Nah.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Dude,
That is pretty simple code to do yourself really....what are you wanting someone else to do your homework?
I'll give you a hint...have the computer generate a random number, then have the user guess on the number. From there you can do stuff like say "Guess higher" or "Guess lower". Then finally when they guess right you can end the guesses.
Other things to add on are print out how many guesses it took to get the right number, ask the user if they want to play again, have a setup option so you can have a selected range.
1.) Guess between 1 - 10 (Easy)
2.) Guess between 1 - 100 (Intermidiate)
3.) Guess between 1 - 1000 (Hard)
To be best, don't start with a random number -- start with the maximum number / 2, then when thy say higher or lower give the midpoint between that number and the current extreme. keep doing that until you get the number. It's a binary search.Originally posted by EnforcerGIS
I'll give you a hint...have the computer generate a random number, then have the user guess on the number. From there you can do stuff like say "Guess higher" or "Guess lower". Then finally when they guess right you can end the guesses.
wow, your post name really tells us about your problem.
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)