| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:学习过程中,又遇新题,请各位指点迷津!!!
只看楼主 加入收藏
经典记忆
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-19
结帖率:16.67%
收藏
 问题点数:0 回复次数:2 
学习过程中,又遇新题,请各位指点迷津!!!
#include <stdio.h>
int main(void)
{
    int chosen = 0;
    int guess = 0;
    int count = 0;
   
    chosen = 20;
    count = 5;
   
    printf("\nThis is a guessing game");
    printf("\nI have a number between 1 and 25"
             " which you must guess.");
   
    for(;count>0;--count)
    {
                          printf("\nYou have %d tr%s left",count,count==1?'y':'ies');
                          printf("\nEnter a guess:  ");
                          scanf("%d",&guess);
                          
                          if(guess==chosen)
                          {
                                           printf("\nYou guessed it!");
                                           return 0;
                          }
                          if(guess<1 || guess>25)
                           printf("\nI said between 1 and 25.");
                          else
                           printf("\nSorry,%d is wrong.",guess);
    }
    printf("\nYou have had three tries and failed.The number was %d.",chosen);
    getchar();
    getchar();
    return 0;
}
执行后提示"0x77c12a16"指令引用的"0x00696573"内存。该内存不能为"read"。
要终止程序,请单击“确定”。
要调试程序,请单击“取消”。
怎么才能正常运行,请各位指点。
                           
搜索更多相关主题的帖子: guess between include number 
2012-08-01 19:04
beyondyf
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:103
帖 子:3282
专家分:12654
注 册:2008-1-21
收藏
得分:0 
printf("\nYou have %d tr%s left",count,count==1?'y':'ies');

printf("\nYou have %d tr%s left",count,(count==1?"y":"ies"));

重剑无锋,大巧不工
2012-08-01 19:15
经典记忆
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2012-7-19
收藏
得分:0 
谢谢指教
2012-08-01 19:39
快速回复:学习过程中,又遇新题,请各位指点迷津!!!
数据加载中...
 
   



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

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