| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 645 人关注过本帖
标题:请问我的C程序为什么不能循环运行
取消只看楼主 加入收藏
索马里的蘑菇
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-8-8
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
请问我的C程序为什么不能循环运行
RT,编译之后只能运行一次,到了应该输入y或者n的时候程序就自动退出了!跪求解答!


#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char another_game='y';
    printf("Hay man!If you wanna try this,press ENTER!\n");
    scanf("%c",&another_game);
    while(another_game=='y');
    {
        int num1=0,num2=0;
        num1=1+rand()%10;
        printf("Look,all you need to do is type a number from 1~10,and press ENTER.Quite simple,uh?Good luck!\n");
        scanf("%d",&num2);
        if(num2==num1)
        printf("You are doing so well!\n");
        else
        printf("Well,maybe you will be lucky next time\n");
        printf("Another round?y/n");
        scanf("%c",&another_game);
      }

   return 0;
}
搜索更多相关主题的帖子: include number simple 
2011-08-08 00:42
索马里的蘑菇
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-8-8
收藏
得分:0 
多谢!现在可以用了!
另外想请问一下为什么 scanf("%*c");也可以清除缓冲区?%*c是什么格式符?
2011-08-08 09:09
索马里的蘑菇
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-8-8
收藏
得分:0 
回6L~谢谢~
2011-08-08 13:17
快速回复:请问我的C程序为什么不能循环运行
数据加载中...
 
   



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

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