CodePudding user response:
Bosses to help me have a look, how to make upCodePudding user response:
Thinking:1. The randomly generated a number
2. Enter a number
3. Judge whether the number and the random Numbers of the input are equal, if not equal, make counter with a variable, is more than 10 is over
CodePudding user response:
Is 2 minutes, give you write a reference
#include
#include
#include
Int main (int arg c, const char * argv []) {
Int num, I, TMP;
Char gaming='y'
srand((unsigned)time(NULL));
While (gaming!='n' & amp; & Gaming!='N') {
Printf (" game start!!! \n");
Num=rand () % 100 + 1;
for (i=0; i<10; I++) {
Printf (" please enter the first guess the number of % d times: ", I + 1);
The scanf (" % d ", & amp; TMP);
If (TMP==num) break;
Else if (TMP & gt; Num) {
Printf (" big and small direction guess again! \n");
} else {
Printf (" small, toward the direction guess again! \n");
}
}
If (I==10) {
Printf (" in this game you lose!" );
} else {
Printf (" congratulations, you win the game!" );
}
Printf (" \ n "(the correct answer: % d), num);
Printf (" whether to continue the game? (enter n or n quit the game) \ n ");
getchar();
The scanf (" % c ", & amp; Gaming);
}
Printf (" game over, welcome next time continue to challenge! \n");
return 0;
}