输入一个数字 (1-7) ,用英文显示对应的星期一到星期日。提示:用 Select Case语句来实现。

2024-11-28 17:09:28
推荐回答(2个)
回答1:

是 switch case吧 你也不说是什么语言
给你个C语言的吧
loop:
printf("请输入1-7:\n");
scanf("%d",&x);
printf("\n");
switch
{case 1;
printf("Monday");
break;
case 2;
printf("Tuesday");
break;
case 3;
printf("Wednesday");
break;
case 4;
printf("Thursday");
break;
case 5;
printf("Friday");
break;
case 6;
printf("Saturday");
break;
case 7;
printf("Sunday");
break;
default:
printf("你输入的啥玩意呀,重新输!");
goto loop;
}

回答2:

#include
void main()
{
int n;
cout<<"请输入数字星期(1-7):";
cin>>n;
cout<<"对应的英文星期为:";
switch(n)
{
case 1:cout<<"Monday";break;
case 2:cout<<"Tuesday";break;
case 3:cout<<"Wednesday";break;
case 4:cout<<"Thursday";break;
case 5:cout<<"Friday";break;
case 6:cout<<"Saturday";break;
case 7:cout<<"Sunday";break;
}
cout<}