在界面上输入数字的月份(1-12),输出对应月份的英文单词的全称,如果输入的数字不合法,给
出提示。
其它要求:
1)用字符串数组(C风格和C++风格)实现
#include <iostream>//c风格
using namespace std;
int main() {
int month;
cin >> month;
char montharr[12][10] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
if (month > 1 && month < 12)
cout << montharr[month - 1] << endl;
else
cout << "输入的数字不正确\n" << endl;
return 0;
}
#include <iostream>//c++风格
using namespace std;
int main() {
int month;
cin >> month;
string montharr[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
if (month > 1 && month < 12)
cout << montharr[month - 1] << endl;
else
cout << "输入的数字不正确\n" << endl;
return 0;
}