医生值班(枚举)

医生值班

Time Limit: 3 Sec  Memory Limit: 128 MB
Submit: 41  Solved: 17
[Submit][Status][Web Board]

Description

医院内科有A,B,C,D,E,F,G,H共七位医生,每人在一周内要值一次夜班,排班的要求是:
(1) A医生值班日比C医生晚1天
(2) D医生值班日比E医生晚2天
(3) B医生值班日比G医生早3天
(4) F医生的值班日在B医生和C医生的值班日之间,且是星期四 
请编写程序,输出每位医生的值班日。值班日以Sunday, Monday ,Tuesday, Wednesday, Thurday, Friday, Saturday分别表示星期日到星期六。

Input

Output

每位医生的值班日

Sample Input

Sample Output

Doctor A is on duty Sunday.Doctor B is on duty Tuesday.Doctor C is on duty Saturday.Doctor D is on duty Wednesday.Doctor E is on duty Monday.Doctor F is on duty Thursday.Doctor G is on duty Friday.

HINT

用枚举变量。

#include<iostream>
using namespace std;
enum work {Sun=7, Mon=1 ,Tues, Wednes, Thur, Fri, Satur};
void shuchu(int a,char e)
{
	cout<<"Doctor "<<e<<" is on duty ";
	switch (a)
	{
	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;
	}

}
int main()
{
int a[8];
a[6]=Thur;
a[2]=2;
a[3]=6;
a[1]=7;
a[7]=5;
a[5]=1;
a[4]=3;
int i,b;char e='A';
for(i=1;i<8;i++)
{b=a[i];
shuchu(b,e);
e++;}


return 0;

}


posted @ 2014-03-09 20:36  IT专业户  阅读(317)  评论(0编辑  收藏  举报