| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1034 人关注过本帖
标题:算温度从摄氏到华氏问题
取消只看楼主 加入收藏
suckdog
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-9-19
结帖率:41.67%
收藏
 问题点数:0 回复次数:0 
算温度从摄氏到华氏问题
这个程序需要把温度先设定为100摄氏度, 然后算出相应的华氏度来, 完成后再把摄氏度减1, 继续算华氏度, 直到摄氏度变成和华氏度一样时程序结束

大家帮我看一下我的程序哪里不对了, 我的程序应该在摄氏-40度的时候华氏也是-40度, 这个时候程序应该终止了,但为什么他还又多减了2次。

#include <iostream>

using namespace std;

int main (int argc, char *argv[])
{
   int cel=100, fah, count;
   
   while (cel-fah!=0)
   {
      fah=cel*9/5+32;
      cout<<"when temperature is "<<cel<<" Celsius, temperature in Fahrenheit is "<<fah<<endl;
      cel--;
   }
   
   cout<<"done";
   cin>>count;
   
   return 0;
}

when temperature is 100 Celsius, temperature in Fahrenheit is 212
when temperature is 99 Celsius, temperature in Fahrenheit is 210
when temperature is 98 Celsius, temperature in Fahrenheit is 208
when temperature is 97 Celsius, temperature in Fahrenheit is 206
when temperature is 96 Celsius, temperature in Fahrenheit is 204
when temperature is 95 Celsius, temperature in Fahrenheit is 203
when temperature is 94 Celsius, temperature in Fahrenheit is 201
when temperature is 93 Celsius, temperature in Fahrenheit is 199
when temperature is 92 Celsius, temperature in Fahrenheit is 197
when temperature is 91 Celsius, temperature in Fahrenheit is 195
when temperature is 90 Celsius, temperature in Fahrenheit is 194
when temperature is 89 Celsius, temperature in Fahrenheit is 192
when temperature is 88 Celsius, temperature in Fahrenheit is 190
when temperature is 87 Celsius, temperature in Fahrenheit is 188
when temperature is 86 Celsius, temperature in Fahrenheit is 186
when temperature is 85 Celsius, temperature in Fahrenheit is 185
when temperature is 84 Celsius, temperature in Fahrenheit is 183
when temperature is 83 Celsius, temperature in Fahrenheit is 181
when temperature is 82 Celsius, temperature in Fahrenheit is 179
when temperature is 81 Celsius, temperature in Fahrenheit is 177
when temperature is 80 Celsius, temperature in Fahrenheit is 176
when temperature is 79 Celsius, temperature in Fahrenheit is 174
when temperature is 78 Celsius, temperature in Fahrenheit is 172
when temperature is 77 Celsius, temperature in Fahrenheit is 170
when temperature is 76 Celsius, temperature in Fahrenheit is 168
when temperature is 75 Celsius, temperature in Fahrenheit is 167
when temperature is 74 Celsius, temperature in Fahrenheit is 165
when temperature is 73 Celsius, temperature in Fahrenheit is 163
when temperature is 72 Celsius, temperature in Fahrenheit is 161
when temperature is 71 Celsius, temperature in Fahrenheit is 159
when temperature is 70 Celsius, temperature in Fahrenheit is 158
when temperature is 69 Celsius, temperature in Fahrenheit is 156
when temperature is 68 Celsius, temperature in Fahrenheit is 154
when temperature is 67 Celsius, temperature in Fahrenheit is 152
when temperature is 66 Celsius, temperature in Fahrenheit is 150
when temperature is 65 Celsius, temperature in Fahrenheit is 149
when temperature is 64 Celsius, temperature in Fahrenheit is 147
when temperature is 63 Celsius, temperature in Fahrenheit is 145
when temperature is 62 Celsius, temperature in Fahrenheit is 143
when temperature is 61 Celsius, temperature in Fahrenheit is 141
when temperature is 60 Celsius, temperature in Fahrenheit is 140
when temperature is 59 Celsius, temperature in Fahrenheit is 138
when temperature is 58 Celsius, temperature in Fahrenheit is 136
when temperature is 57 Celsius, temperature in Fahrenheit is 134
when temperature is 56 Celsius, temperature in Fahrenheit is 132
when temperature is 55 Celsius, temperature in Fahrenheit is 131
when temperature is 54 Celsius, temperature in Fahrenheit is 129
when temperature is 53 Celsius, temperature in Fahrenheit is 127
when temperature is 52 Celsius, temperature in Fahrenheit is 125
when temperature is 51 Celsius, temperature in Fahrenheit is 123
when temperature is 50 Celsius, temperature in Fahrenheit is 122
when temperature is 49 Celsius, temperature in Fahrenheit is 120
when temperature is 48 Celsius, temperature in Fahrenheit is 118
when temperature is 47 Celsius, temperature in Fahrenheit is 116
when temperature is 46 Celsius, temperature in Fahrenheit is 114
when temperature is 45 Celsius, temperature in Fahrenheit is 113
when temperature is 44 Celsius, temperature in Fahrenheit is 111
when temperature is 43 Celsius, temperature in Fahrenheit is 109
when temperature is 42 Celsius, temperature in Fahrenheit is 107
when temperature is 41 Celsius, temperature in Fahrenheit is 105
when temperature is 40 Celsius, temperature in Fahrenheit is 104
when temperature is 39 Celsius, temperature in Fahrenheit is 102
when temperature is 38 Celsius, temperature in Fahrenheit is 100
when temperature is 37 Celsius, temperature in Fahrenheit is 98
when temperature is 36 Celsius, temperature in Fahrenheit is 96
when temperature is 35 Celsius, temperature in Fahrenheit is 95
when temperature is 34 Celsius, temperature in Fahrenheit is 93
when temperature is 33 Celsius, temperature in Fahrenheit is 91
when temperature is 32 Celsius, temperature in Fahrenheit is 89
when temperature is 31 Celsius, temperature in Fahrenheit is 87
when temperature is 30 Celsius, temperature in Fahrenheit is 86
when temperature is 29 Celsius, temperature in Fahrenheit is 84
when temperature is 28 Celsius, temperature in Fahrenheit is 82
when temperature is 27 Celsius, temperature in Fahrenheit is 80
when temperature is 26 Celsius, temperature in Fahrenheit is 78
when temperature is 25 Celsius, temperature in Fahrenheit is 77
when temperature is 24 Celsius, temperature in Fahrenheit is 75
when temperature is 23 Celsius, temperature in Fahrenheit is 73
when temperature is 22 Celsius, temperature in Fahrenheit is 71
when temperature is 21 Celsius, temperature in Fahrenheit is 69
when temperature is 20 Celsius, temperature in Fahrenheit is 68
when temperature is 19 Celsius, temperature in Fahrenheit is 66
when temperature is 18 Celsius, temperature in Fahrenheit is 64
when temperature is 17 Celsius, temperature in Fahrenheit is 62
when temperature is 16 Celsius, temperature in Fahrenheit is 60
when temperature is 15 Celsius, temperature in Fahrenheit is 59
when temperature is 14 Celsius, temperature in Fahrenheit is 57
when temperature is 13 Celsius, temperature in Fahrenheit is 55
when temperature is 12 Celsius, temperature in Fahrenheit is 53
when temperature is 11 Celsius, temperature in Fahrenheit is 51
when temperature is 10 Celsius, temperature in Fahrenheit is 50
when temperature is 9 Celsius, temperature in Fahrenheit is 48
when temperature is 8 Celsius, temperature in Fahrenheit is 46
when temperature is 7 Celsius, temperature in Fahrenheit is 44
when temperature is 6 Celsius, temperature in Fahrenheit is 42
when temperature is 5 Celsius, temperature in Fahrenheit is 41
when temperature is 4 Celsius, temperature in Fahrenheit is 39
when temperature is 3 Celsius, temperature in Fahrenheit is 37
when temperature is 2 Celsius, temperature in Fahrenheit is 35
when temperature is 1 Celsius, temperature in Fahrenheit is 33
when temperature is 0 Celsius, temperature in Fahrenheit is 32
when temperature is -1 Celsius, temperature in Fahrenheit is 31
when temperature is -2 Celsius, temperature in Fahrenheit is 29
when temperature is -3 Celsius, temperature in Fahrenheit is 27
when temperature is -4 Celsius, temperature in Fahrenheit is 25
when temperature is -5 Celsius, temperature in Fahrenheit is 23
when temperature is -6 Celsius, temperature in Fahrenheit is 22
when temperature is -7 Celsius, temperature in Fahrenheit is 20
when temperature is -8 Celsius, temperature in Fahrenheit is 18
when temperature is -9 Celsius, temperature in Fahrenheit is 16
when temperature is -10 Celsius, temperature in Fahrenheit is 14
when temperature is -11 Celsius, temperature in Fahrenheit is 13
when temperature is -12 Celsius, temperature in Fahrenheit is 11
when temperature is -13 Celsius, temperature in Fahrenheit is 9
when temperature is -14 Celsius, temperature in Fahrenheit is 7
when temperature is -15 Celsius, temperature in Fahrenheit is 5
when temperature is -16 Celsius, temperature in Fahrenheit is 4
when temperature is -17 Celsius, temperature in Fahrenheit is 2
when temperature is -18 Celsius, temperature in Fahrenheit is 0
when temperature is -19 Celsius, temperature in Fahrenheit is -2
when temperature is -20 Celsius, temperature in Fahrenheit is -4
when temperature is -21 Celsius, temperature in Fahrenheit is -5
when temperature is -22 Celsius, temperature in Fahrenheit is -7
when temperature is -23 Celsius, temperature in Fahrenheit is -9
when temperature is -24 Celsius, temperature in Fahrenheit is -11
when temperature is -25 Celsius, temperature in Fahrenheit is -13
when temperature is -26 Celsius, temperature in Fahrenheit is -14
when temperature is -27 Celsius, temperature in Fahrenheit is -16
when temperature is -28 Celsius, temperature in Fahrenheit is -18
when temperature is -29 Celsius, temperature in Fahrenheit is -20
when temperature is -30 Celsius, temperature in Fahrenheit is -22
when temperature is -31 Celsius, temperature in Fahrenheit is -23
when temperature is -32 Celsius, temperature in Fahrenheit is -25
when temperature is -33 Celsius, temperature in Fahrenheit is -27
when temperature is -34 Celsius, temperature in Fahrenheit is -29
when temperature is -35 Celsius, temperature in Fahrenheit is -31
when temperature is -36 Celsius, temperature in Fahrenheit is -32
when temperature is -37 Celsius, temperature in Fahrenheit is -34
when temperature is -38 Celsius, temperature in Fahrenheit is -36
when temperature is -39 Celsius, temperature in Fahrenheit is -38
when temperature is -40 Celsius, temperature in Fahrenheit is -40
when temperature is -41 Celsius, temperature in Fahrenheit is -41
when temperature is -42 Celsius, temperature in Fahrenheit is -43

搜索更多相关主题的帖子: 温度 摄氏 华氏 
2010-04-07 01:52
快速回复:算温度从摄氏到华氏问题
数据加载中...
 
   



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

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