输入月份号,程序输出该月的英文名,如输入3,则输出March,用指针数组实现

如题所述

第1个回答  2010-10-10
刚写的。。自己看看吧。。希望可以帮到你。。。

#include <iostream>
#include <string>
using namespace std;

int main()
{
string name_of_months[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int n;
cin >> n;
cout << name_of_months[n-1]<< endl;
return 0;
}
第2个回答  2010-10-10
#include <iostream>
#include <string>
using namespace std;

int main()
{
string name_of_months[12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
int n;
cin >> n;
cout << name_of_months[n+1] << endl;
return 0;
}本回答被提问者采纳
相似回答