C语言 利用函数编写一个温度转化的程序

#include 

double TemperatureTrans(double dblTemperature,char cType)
{
	double temperature;
	if(cType=='c')
		temperature=dblTemperature*1.8+32;
	else if(cType=='f')
		temperature=(dblTemperature-32)/1.8;
	return temperature;
}

int main()
{
	char cType;
	double dblTemperature,temperature;
	printf("请输入要转化的温度和对应形式:");
	scanf("%lf,%c",&dblTemperature,&cType);
	temperature=TemperatureTrans(dblTemperature,cType);
	printf("转化后的温度为:%lf\n",temperature);
	return 0;
}

你可能感兴趣的:(学习作业,c语言,c++,开发语言)