1、a医生值班日比c医生晚一天
2、d医生值班日比e医生晚两天
3、b医生值班日比g医生早三天
4、f医生值班日在b医生和c医生值班日之间,且在星期四
请写出程序,输出每位医生的值班日。
#include<iostream>
using namespace std;
void main()
{
enum weekday{sun,mon,tus,wed,thu,fri,sat};
enum weekday day;
int a,b,c,d,e,f,g,loop;
char ch=”A”;
f=thu;
for (a=0;a<=sat;a++)
if (a!=f)
for (b=0;b<=sat;b++)
if ((a!=b) && (f>b))
for (c=0;c<=sat;c++)
if (a!=c && b!=c && c!=f && (f<c))
for (d=0;d<=sat;d++)
if (a!=d && b!=d && c!=d && d!=f && (a==c+1))
for (e=0;e<=sat;e++)
if (a!=e && b!=e && c!=e && d!=e && e!=f&&(d==e+2))
for (g=0;g<=sat;g++)
if (a!=g && b!=g && c!=g && d!=g && e!=g && g!=f && (g==b+3))
for (loop=0;loop<7;loop++)
{
cout<<“Doctor”<<char(ch+loop)<<“:”;
switch(loop+1)
{
case 1:day=weekday(a);break;
case 2:day=weekday(b);break;
case 3:day=weekday(c);break;
case 4:day=weekday(d);break;
case 5:day=weekday(e);break;
case 6:day=weekday(f);break;
case 7:day=weekday(g);break;
}
switch(day)
{
case sun:cout<<“Sunday”<<endl;break;
case mon:cout<<“Monday”<<endl;break;
case tus:cout<<“Thusday”<<endl;break;
case wed:cout<<“Wednesday”<<endl;break;
case thu:cout<<“Thurday”<<endl;break;
case fri:cout<<“Friday”<<endl;break;
case sat:cout<<“Saturday”<<endl;break;
}
}
}
运行程序,没有结果,求高手指出错误
20
#include<iostream> using namespace std; void main() { enum weekday{mon,tus,wed,thu,fri,sat,sun}; enum weekday day; int a,b,c,d,e,f,g,loop; char ch="A"; f=thu; for (a=0;a<=sun;a++) if (a!=f) for (b=0;b<=sun;b++) if ((a!=b) && (f>b)) for (c=0;c<=sun;c++) if (a!=c && b!=c && c!=f && (f<c)) for (d=0;d<=sun;d++) if (a!=d && b!=d && c!=d && d!=f && (a==c+1)) for (e=0;e<=sun;e++) if (a!=e && b!=e && c!=e && d!=e && e!=f&&(d==e+2)) for (g=0;g<=sun;g++) if (a!=g && b!=g && c!=g && d!=g && e!=g && g!=f && (g==b+3)) for (loop=0;loop<7;loop++) { cout<<"Doctor"<<char(ch+loop)<<":"; switch(loop+1) { case 1:day=weekday(a);break; case 2:day=weekday(b);break; case 3:day=weekday(c);break; case 4:day=weekday(d);break; case 5:day=weekday(e);break; case 6:day=weekday(f);break; case 7:day=weekday(g);break; } switch(day) { case sun:cout<<"Sunday"<<endl;break; case mon:cout<<"Monday"<<endl;break; case tus:cout<<"Thusday"<<endl;break; case wed:cout<<"Wednesday"<<endl;break; case thu:cout<<"Thurday"<<endl;break; case fri:cout<<"Friday"<<endl;break; case sat:cout<<"Saturday"<<endl;break; } } char pause = getchar(); }
你的起始位置不太对,试试这个,这个程序应该是本意周一是一周的第一天