标题:do...while 的循环问题 求助
取消只看楼主
NordicNavy
Rank: 1
来 自:地球
等 级:新手上路
帖 子:30
专家分:0
注 册:2008-10-20
 问题点数:0 回复次数:3 
do...while 的循环问题 求助
感觉code 是对的,就是编译时不显示,,求助。。刚刚学C
#include <stdio.h>

main()
{
      int temp;
      float celsius;
      char repeat;
      do
      {
           printf("Input a temperature:");
           scanf("%d", &temp);
           celsius=(5.0/9.0)*(temp-32);
           printf("The converted F format is %.2f\n", celsius);
           printf("Do you have other data need to be converted?\n");
           printf("Press Y or y if you want to continue");
           repeat=getchar();
           putchar('\n');
           }
      while (repeat=='Y' || repeat=='y');
      
      }
搜索更多相关主题的帖子: continue include repeat 
2008-10-21 04:51
NordicNavy
Rank: 1
来 自:地球
等 级:新手上路
帖 子:30
专家分:0
注 册:2008-10-20
得分:0 
问题没有解决
不好意思,我们不是一个时区, 我刚刚QCh。。

问题没有解决,我在while语句后加 return 0;程序还是可以编译,但输入第一个数值后自动关闭。
如果在while语句后加system("pause"),倒是进行了计算,但根本不容判断 y or Y的出现。。。
我用的是 dev c++
谢谢ls
2008-10-21 15:34
NordicNavy
Rank: 1
来 自:地球
等 级:新手上路
帖 子:30
专家分:0
注 册:2008-10-20
得分:0 
有朋友再帮我看看么,否则后面的都没法继续
o...while 的循环问题 求助
感觉code 是对的,就是编译时不显示,,求助。。刚刚学C
#include <stdio.h>

main()
{
      int temp;
      float celsius;
      char repeat;
      do
      {
           printf("Input a temperature:");
           scanf("%d", &temp);
           celsius=(5.0/9.0)*(temp-32);
           printf("The converted F format is %.2f\n", celsius);
           printf("Do you have other data need to be converted?\n");
           printf("Press Y or y if you want to continue");
           repeat=getchar();
           putchar('\n');
           }
      while (repeat=='Y' || repeat=='y');      
      }
问题没有解决,我在while语句后加 return 0;程序还是可以编译,但输入第一个数值后自动关闭。
如果在while语句后加system("pause"),倒是进行了计算,但根本不容判断 y or Y的出现。。。
我用的是 dev c++
谢谢ls
2008-10-21 18:37
NordicNavy
Rank: 1
来 自:地球
等 级:新手上路
帖 子:30
专家分:0
注 册:2008-10-20
得分:0 
谢谢,开始工作了
谢谢,工作了。
只是不懂为什么选择 Y y 后还要回车。。。不管怎么说, 程序可以继续了
2008-10-21 18:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-239538-1-1.html




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

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