c++ 输入一个1~7的数字,输出一个英文单词(礼拜几)(要求使用指针数组)
嗯
#include <iostream>
using namespace std;
int main()
{
const char *str[8] = { "Monday","Tuesday", "Wednesday", "Tuesday", "Friday", "Saturday", "Sunday" };
int day = 0;
cout <<"请输入数字:";
cin >> day;
while (day < 1 || day>7)
{
cout << "输入有误!请重新输入";
cin >> day;
}
cout << str[day-1] << endl;
return 0;
}