Sentiment: This is a starting point, I am a sophomore, but also this dish, just started to write games, this game is very simple, using random numbers to guess the size!
#include <stdlib.h> #include <stdio.h> #include <time.h>int main () { int n; int number; Srand ((unsigned) time (NULL)); Number = rand ()%100; printf ("Game starts!\n"); while (1) { printf ("Please enter an integer between 1-100:"); scanf ("%d", &n); if (n = = number) { printf ("Congratulations you guessed it, the game is over.") \ n "); break; } if (n > Number) printf ("Big \n\n\n"); if (n < number) printf ("Small \n\n\n"); } return 0;}
Note: I write this simple game just to start practicing the use of random numbers, I will play the game here, the algorithm and data structure of the code on the csdn over there, the next time to submit a Java to write the aircraft War and C + + version of the snake!!! ITCSC man can't confess!!! up!up!up!
The csdn:http://blog.csdn.net/empire_ing of the great Lord
C language to write a simple game