一.问题描述
输入一个0~6的数字,转化成数字输出
二.设计思路
1.输入0~6中任意一个数字
2.需要运用多重分支结构
3.选用switch语句
三.程序流程图
画不出来
四.代码实现
#include <iostream>
using namespace std;
int main()
{
int day;
cin>>day;
switch(day){
case 0:
cout<<"Sunday"<<endl;
break;
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;
default:
cout<<"Day out of range Sunday...saturday"<<endl;
break;
}
return 0;
}
运行结果如下图所示
标签:case,break,cout,int,天天,小时,打卡,day From: https://www.cnblogs.com/my0326/p/17323874.html