注册 登录
编程论坛 C++教室

温度测试程序有问题请教!

含笑半步颠 发布于 2007-03-05 21:15, 734 次点击

// temperature conversion application
#include <iostream.h>
void main()
{
// input temperature, numeric input
int tempinput;
// output temperature, numeric output
int tempoutput;
// input conversion type, single character
// "C" will be used to represent C to F.
// "F" will be used to represent F to C.
char conversiontype;
// input the temperature
cin >> tempinput;
// input conversion type
cin >> conversion type;
// conditionals below
if (conversiontype == 67)
// calculation code here for C to F
tempoutput = (1.8 * tempinput) + 32;
if (conversiontype == 70)
// calculation code here for F to C
tempoutput = (tempinput - 32) * 0.555;
cout << tempout << endl;
}

vc++ 6.0上输出有错
1 error(s), 0 warning(s)
但是我检查了多次不知道错在哪!?
请多指教

[此贴子已经被作者于2007-3-7 22:25:22编辑过]

5 回复
#2
wfpb2007-03-05 21:38
cin >> conversion type;
cin >> conversiontype;
#3
虫虫飞ya飞2007-03-07 16:18
#include<iostream.h>
void main()
{

int tempinput;

double tempoutput;

int conversiontype;

cin>>tempinput;

cin>>conversiontype;

if(conversiontype==67)

tempoutput=(1.8*tempinput)+32;

if(conversiontype==70)

tempoutput=(tempinput-32)*0.555;

cout<<tempoutput<<endl;

}
上面是正确呢,你自己慢慢对着看吧你错的不止一个地方.
#4
含笑半步颠2007-03-07 22:23
哦~ 谢谢!
#5
skybehind2007-03-08 15:57

哦..

#6
shizhusz1102007-03-08 20:35
tempoutput做成double好点
1