Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /************************************/
- /** 20140506 Ultimate Password **/
- /** Maker : Yan **/
- /** E-Mail : ssas1115577@gmail.com **/
- /** Date : 2014/05/26 am.10:03 **/
- /************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int compare(int, int);
- void main()
- {
- printf("-------------Start Game !-------------\n");
- srand(time(NULL));
- int random = rand() % (100 - 0 + 1) + 0;
- int max_limit = 100, min_limit = 1;
- while(1)
- {
- printf("The range is %d to %d.\n", min_limit, max_limit);
- printf("Enter a number of you guess: ");
- int input = 0;
- scanf("%d", &input);
- switch(compare(input, random))
- {
- case 0:
- printf("The number is smaller.\n");
- max_limit = input;
- break;
- case 1:
- printf("The number is larger.\n");
- min_limit = input;
- break;
- case 2:
- printf("\nComgratulations, you get the number !\n");
- printf("--------------End Game !--------------\n");
- system("pause");
- return;
- }
- }
- }
- int compare(int input, int random)
- {
- if(input > random)
- {
- return 0;
- }
- else if(input < random)
- {
- return 1;
- }
- else if(input = random)
- {
- return 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement