Problem G: C语言实验——输入数字星期,输出英文(选择结构-switch)
Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 205 Solved: 124
[ Submit][ Status][ Web Board]
Description
从键盘上输入数字星期,然后输出它的英文: 其对应关系是 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday 7 Sunday
Input
从键盘输入数字星期,
Output
输入的数字在1-7之内,则输出该数字对应的英文表示
Sample Input
2
Sample Output
Tuesday
HINT
#include <iostream>
using namespace std;
int main ()
{
int week;
cin>>week;
switch(week)
{
case 1:cout<<"Monday"<<endl;break;
case 2:cout<<"Tuesday"<<endl;break;
case 3:cout<<"Wednesday"<<endl;break;
case 4:cout<<"Thursday"<<endl;break;
case 5:cout<<"Friday"<<endl;break;
case 6:cout<<"Saturday"<<endl;break;
case 7:cout<<"Sunday"<<endl;break;
default:cout<<"error"<<endl;
}
return 0;
}