码迷,mamicode.com
首页 > 其他好文 > 详细

猜字游戏

时间:2017-11-13 23:04:39      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:null   scan   blog   void   srand   pre   随机   not   游戏   

 1 /* Note:Your choice is C IDE */
 2 #include "stdio.h"
 3 #include <stdlib.h>
 4 #include<time.h>
 5 void main()
 6 {
 7    int i,j;
 8    srand((unsigned)time(NULL));//生成不重复的随机数stdlib.h
 9    j=rand() %100;//
10    printf("!!!!请输入一个100以内的整数!!!\n");
11    while(1)
12 
13 {
14 scanf("%d",&i);
15 if(i<j)
16 {    
17 printf("太小了\n");    
18     
19 }else if(i>j){
20 printf("太大了\n");    
21     
22 }else{
23     printf("恭喜,猜对了!!\n");
24     
25     break;
26 }
27 }
28 }

 

猜字游戏

标签:null   scan   blog   void   srand   pre   随机   not   游戏   

原文地址:http://www.cnblogs.com/zoute/p/7828371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!