2 u013117230 u013117230 于 2014.02.06 22:14 提问

c枚举运算有问题请教各位geek

#include"stdio.h"
typedef enum {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}weekday;
weekday previousday(weekday nowaday);
weekday nextday(weekday nowaday);
int main()
{
int choise;
weekday nowaday,theday;
printf("please input nowaday");
scanf("%c",&nowaday);
printf("please input your choise,0:priviousday 1:nextday");
scanf("%d",&choise);
choise==0?theday=previousday(nowaday):theday=nextday(nowaday);
printf("%c",theday);
}

weekday previousday(weekday nowaday)
{
nowaday=(weekday)(nowaday+1);
return (weekday)(nowaday%7);
}
weekday nextday(weekday nowaday)
{
nowaday=(weekday)(nowaday-1);
return (weekday)(nowaday%7);
}
请帮忙看看这个问题出在哪儿了?谢了。

1个回答

tlxzsz
tlxzsz   2014.02.13 21:50

#include "stdafx.h"
#include"stdio.h"
typedef enum {Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday}weekday;
weekday previousday(weekday nowaday);
weekday nextday(weekday nowaday);
int main()
{
int choise;
weekday nowaday,theday;
printf("please input nowaday");
scanf("%d",&nowaday);
printf("please input your choise,0:priviousday 1:nextday");
scanf("%d",&choise);
//choise==0?theday=previousday(nowaday):theday=nextday(nowaday);
theday=choise==0?previousday(nowaday):nextday(nowaday);
printf("%d",theday);
}

weekday previousday(weekday nowaday)
{
nowaday=(weekday)(nowaday-1);
return (weekday)(nowaday%7);
}
weekday nextday(weekday nowaday)
{
nowaday=(weekday)(nowaday+1);
return (weekday)(nowaday%7);
}
试试,看看哪里不明白?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!