|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
while(!(std::cin>>typeIn))
{
std::cin.ignore(100,'\n');
std::cin.clear();
std::cout << "请以【xx.x】的形式输入温度: ";
}
do
{
std::cout << "请以【xx.x C】或【xx.x F】的形式输入温度: ";;
std::cin>>typeIn;
}while((typeIn!='c')&(typeIn!='C')&(typeIn!='F')&(typeIn!='f'));
std::cout<<"\n";
switch(typeIn)
{
case 'c':
case 'C':
tempOut=(tempIn*RATIO)+ADD_SUBTRACT;
tempOut='F';
tempIn='C';
break;
case 'f':
case 'F':
tempOut=(tempIn-ADD_SUBTRACT)/RATIO;
break;
default:
typeOut='E';
break;
}
if(typeOut !=1)
{
std::cout <<tempIn<<typeIn<<"="<<tempOut<<typeIn<<"\n\n";
}
else
{
std::cout<<"你输入有误"<<"\n\n";
}
std::cin.eof()
return 0;
}
我想问一下怎么用if来做判断,当while满足要求时就不执行do while里面的代码就不被执行直接跳过,如果while不满足条那就执行do while语句
|
|