问题:
解答:
#include <iostream>
using namespace std;
const int yearToMonth = 12;
int main()
{
short age = 0;
cout << "请输入您的芳龄:" << endl;
cin >> age;
int months = age * yearToMonth;
cout << age << "岁已经在世" << months << "月了" << endl;
return 0;
}
运行结果:
考查点:
- const
注意:
cosnt修饰的变量不能修改,称其为只读变量.
2024年8月22日20:19:55