#include <iostream>
using namespace std;
// 编写一个程序,其中的main()调用一个用户定义的函数(以摄氏温度值为参数,并返回相应的华氏温度值)
double CelsiusToFahrenheit(double); //声明调用函数原型
int main(){
double celsius,fahrenheit;//定义变量摄氏温度和华氏温度
cout<<"please enter a Celsius value: ";
cin>>celsius;
fahrenheit=CelsiusToFahrenheit(celsius);
cout<<celsius<<" degrees Celsius is "<<fahrenheit<<" degrees Fahrenheit."<<endl;
return 0;
}
/**
摄氏温度转华氏温度函数
*/
double CelsiusToFahrenheit(double celsius){
return 1.8*celsius+32.0;
}
C++Primer Plus (第6版)中文版 第2章 2.7 编程练习 第5题
最新推荐文章于 2025-04-28 17:23:47 发布
