首页 > 试题广场 >

输入一个表示星期几的数,然后输出相应的英文单词。要求:使用指

[问答题]

输入一个表示星期几的数,然后输出相应的英文单词。要求:使用指针数组实现。

推荐
#include<iostream>
using namespace std;
int main()
{
char *weekday[7]
= { "sunday", "monday", "tuesday","wednesday", "thursday", "friday", "saturday" };
  int d;
  cout << "please input week day: ";
  cin >> d;
  if( d>=0 && d<=6 )
cout << d << "---" << *( weekday + d ) <<endl;
  else
 cout << "input error!" << endl;
}

发表于 2018-05-07 11:42:50 回复(0)