| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 366 人关注过本帖
标题:猜数游戏
取消只看楼主 加入收藏
陈伟煌08
Rank: 1
等 级:新手上路
帖 子:4
专家分:5
注 册:2014-9-20
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:0 
猜数游戏
#include<stdio.h>
#include<stdlib.h>
#include<time.h>/*头文件*/
void main()
{
    int ia,ib;
    long ic;
    char ca,cb,cc;
    time_t beg,end; /*定义时间变量*/
    printf("Do you want to play this game?('y' or 'n')\n");
    ca=getchar();
    while(ca!='n') /*循环*/
    {
        ia=rand(100); /*产生随机数*/
        printf("Now the system have produced a random number between 0 to 99,enter your guess:\n");
        scanf("%d",&ib);
        time(&beg); /*获取当前时间*/
        while(ib!=ia)
        {
            if(ib>ia)
            {
                printf("please input a smaller number!\n");
            }
            if(ib<ia)
            {
                printf("please input a bigger number!\n");
            }
            scanf("%d",&ib);
        }
        time(&end); /*获取结束时间*/
        ic=end-beg; /*计算所花时间*/
        printf("Success!It took you %ld seconds to finish\n",ic);
        {
            if(ic<15)
            {
                printf("you are clever!\n");
            }
            else if(ic<25)
            {
                printf("you are normal!\n");
            }
            else
            {
                printf("you are stupid!\n");
            }
        }
        getchar();
        printf("Do you want to play this game?('y' or 'n')\n");
        scanf("%c",&ca);
    }
}

这是个猜数的程序,可是为什么正确一次后想要再次游戏,不管输入什么数字,程序总是输出“please input a bigger number!”   ???
搜索更多相关主题的帖子: produced between include system number produced between include system number 
2014-10-19 13:22
快速回复:猜数游戏
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015288 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved