C++ Primer plus 2.7.4 这题没啥难度
#include<iostream>
using namespace std;
int main()
{
int age,mouths;
cout<<"Enter your age :"<<endl;
cin>>age;
mouths=age*12;
cout<<"your age equals "<<mouths<<" mouths!"<<endl;
return 0;
}
2.7.5 主要不清楚函数怎么用 声明啊 调用啊 定义啊 都还不是特别熟练 记得的是:double和int之间的转换会有warning的
#include<iostream>
using namespace std;
double Fahrenheit(double n);
int main()
{
double n;
cout<<"please enter a celsius value :"<<endl;
cin>>n;
double m=Fahrenheit(n);
cout<<n<<" degrees celsius is "<<m<<" degrees Fahrenheit."<<endl;
return 0;
}
double Fahrenheit(double n)
{
return 1.8*n+32.0;
}
先要函数声明,需要得到的数为m,调用函数并赋值给它,写完主函数后写功能函数,可是原来写m=1.8*n+32.0 后来return m却不能运行,whywhywhy?
明天问大神 晚上继续刷题 fighting