一个很弱的问题,cin的具体用法??
#include<iostream> using namespace std;
int main()
{
float t,tc,tf;
char corf;
const float fac=1.8,inc=32;
cout<<"Enter temperature: ";
cin>>t; // 输入温度值
cin>>corf; // 指出是攝氏(C)或华氏(F)
if(corf=='c'||corf=='C')
{
tc=t;
tf=t*fac+inc;
}
else
if(corf=='F'||corf=='f')
{
tf=t;
tc=(t-inc)/fac;
}
else tc=tf=0.0;
cout<<endl<<"The temperature is: ";
cout<<tc<<"C="<<tf<<"F\n";
return 0;
}
程序运行结果如下:
Enter temperature: 40.2C
The temperature is 40.2C=104.36F
cin的具体用法??自己会区别整型跟字符型???