首页 > 其他分享 >3-8

3-8

时间:2023-03-10 19:34:08浏览次数:21  
标签: 摄氏温度 return double 华氏温度 32 include

编写函数把华氏温度转换为摄氏温度﹐公式为
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 }

 

标签:,摄氏温度,return,double,华氏温度,32,include
From: https://www.cnblogs.com/YUZE2001/p/17204491.html

相关文章