In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the C language how to achieve simple number guessing Mini Game, the article is very detailed, has a certain reference value, interested friends must read it!
The number guessing game is to make the game machine randomly generate a positive integer less than 100.
The user enters a number to guess it, which requires you to write a program to automatically compare it with the randomly generated number.
And hint big ("Too big"), or small ("Too small"), equal means guessed
If you guess, end the program. The program is also required to count the number of guesses. If you guess the number once, it prompts "Bingo!"
If the number is guessed within 3 times, it prompts "Lucky You!"
If the number is guessed more than 3 times but within N (> 3) times (including the Nth time), the prompt is "Good Guess!"
If you don't guess more than N times, prompt "Game Over" and end the program.
If the user enters a negative number and also outputs "Game Over" before reaching N times, and ends the program
# include # include int main () {printf ("the rules of the game are as follows: there are two modes in the game that require the user to enter the number 1 or 2 to choose, and then the user enters his own guess and prompts to approach the answer\ n") Printf ("if guessing the number once prompts Bingo!\ nIf it is guessed within 3 times, it prompts Lucky You!\ nIf it is more than 3 times but includes the Nth time within N (> 3) times, it prompts Good Guess!\ nIf it is not guessed more than N times, it prompts Game Over\ nIf the user enters a negative number before N times, it also outputs Game Over\ n") PlaySound ("background", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP); int aMagic NMagazine iMagnum; printf ("Please choose your mode: 1. The computer randomly generates 0-10 maximum guesses; 2. The default maximum number is 5); printf ("Please enter the mode code of your choice:"); scanf ("% d", & n); printf ("the game has started"); if (unsigned 1) {srand ((unsigned) time (NULL)); a=rand () 0; N=rand (); for (iTune1) printf ("guess big\ n"); else if (x > 0&&x0&&x)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.