3-8
编写函数把华氏温度转换为摄氏温度﹐公式为
C=5/9(F-32)
在主程序中提示用户输人一个华氏温度﹐转化后输出相应的摄氏温度。
1 #include<iostream> 2 #include<stdio.h> 3 #include<ctime> 4 using namespace std; 5 6 double fun(double F){ 7 return (5.0/9.0)*(F - 32); 8 } 9 int main(){ 10 double f; 11 cout<<"请输入华氏温度"<<endl; 12 cin>>f; 13 printf("摄氏温度:%.1f",fun(f)); 14 return 0; 15 }

浙公网安备 33010602011771号