//#include "stdafx.h"//If the vc++6.0, with this line.
#include <iostream>
using namespace std;
int main(int argc,char *argv[]){
const char *s[10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int w;
cout << "Please w(int 1~7)...\nw=";
if(!(cin >> w) || w<1 || w>7){
cout << "Input error, exit...\n";
return 0;
}
cout << w << " --> " << s[w-1] << endl;
return 0;
}
运行样例:
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/1b4c510fd9f9d72ac85dbf4fd92a2834349bbba3?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
本回答被网友采纳