输入一个表示星期几的数,然后输出相应的英文单词。要求:使用指针数组实现。
#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; }
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题