#include <stdio.h> #include <stdlib.h> #include <time.h>void game () {int input = 0;printf ("Welcome to the Guess number game \ n Srand ((unsigned int) time (NULL)), int ret = rand ()% 100;do{printf ("Please enter the number you guessed:>"); scanf_s ("%d", &input); if ( Input > Ret) {printf ("you guessed too big \ n");} else if (Input < ret) {printf ("you guessed too small \ n");} else{printf ("Congratulations on your guess right \ n"); break;}} while (1);} void menu () {printf ("************************\n");p rintf ("* * * 1. Start Game ********\n");p rintf ("* * * 0. Exit game ********\n"); printf ("************************\n");} int main () {int choice = 1;while (choice) {menu ();p rintf ("Please select:>"), scanf_s ("%d", &choice); switch (choice) {Case 1: Game (); break;default:break;}} System ("pause"); return 0;}
This article is from the "vs LV" blog, so be sure to keep this source http://survive.blog.51cto.com/10728490/1702474
"C-language" Guess number game