//C++输入输出 //向用户提出一个“y/N”问题 //然后把用户输入的值赋给 answer 变量 //针对用户输入'Y''y'和'N''n'进行过滤 #includeusing namespace std; int main() { char answer; cout<<"请问可以格式化您的硬盘吗?【Y/N】"<<"n"; cin>>answer; switch(answer) { case 'Y': case 'y': cout<<"可以 测试"<<"n";break; case 'N': case 'n': cout<<"不可以 测试"<<"n";break; default: cout<<"您的输入不符合要求"<<"n";break; } return 0; } //编写一个“温度单位转换程序” //提示用户 以 [xx.x C] 或 [xx.x F]的格式输入 //要求:输入:34.2 C自动转换为90.32 F并输出 #include using namespace std; int main() { //华氏温度 == 摄氏温度 * 9.0/5.0 +32 const unsigned short ADD_SUBTRACT = 32; const double RATIO = 9.0/5.0; double tempIn,tempOut; char typeIn,typeOut; cout<<"请 以 [xx.x C] 或 [xx.x F]的格式输入一个温度:"; cin>>tempIn>>typeIn; cin.ignore(100,'n'); cout<<"n"; switch(typeIn) { case 'C': case 'c': tempOut=tempIn*RATIO+ADD_SUBTRACT; typeOut='F'; typeIn='C'; break; case 'F': case 'f': tempOut=(tempIn-ADD_SUBTRACT)/RATIO; typeOut='C'; typeIn='F'; break; default: typeOut='E';break; } if(typeOut!='E') { cout<



