马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
用code blocks 编写的程序#include <iostream>
using namespace std;
int main()
{
cout<<"请【xx.x c】或者[xx.x f]的形式输入温度"<<endl;
double tempin,tempout;
char typein,typeout;
const double RADIO = 9.0/5.0;
const unsigned short REST =32;
cin>>tempin;
cin>>typein;
cin.ignore(100,'\n');
switch(typein)
{
case 'c':
case 'C':
tempout=tempin*RADIO+REST;
typeout='F';
break;
case 'f':
case 'F':
tempout=(tempin-REST)/RADIO;
typeout='C';
break;
default:
typeout='E';
break;
}
if (typeout != 'E')
{
cout<<tempin<<typein
<<'=='<<tempout<<typeout;
}
else
cout<<"输入错误";
return 0;
}
输入的是
32.4 c
调试时
不知道为什么 |