Guess the number (including code) The computer automatically generates a number randomly, and the user guesses the number by inputting the number to match the random number and display whether it is correct or not

Guess the number (including code) The computer automatically generates a number randomly, and the user guesses the number by inputting the number to match the random number and display whether it is correct or not

My actual experience is for reference only.
The following is the running result of the program
Guess the number

The following is the program code

/*
Program function: number guessing game, the computer automatically generates a number at random, the 'person' guesses the number by inputting the number, and matches with the random number
. number and display the number of entries.
*/
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{ int magic;/ the number the computer thinks / int guess;/ the number people guess / int counter;/ A counter variable that records the number of times people guess the number / srand((unsigned)time(NULL)); magic = rand() % 100 + 1;/*The computer thinks of a number between [1-100], which is magic* / counter = 0; /* counter initialized to 0 times */ do { printf("please guess a magic number:\n"







Guess you like

Origin blog.csdn.net/qq_43736343/article/details/102577071