枚举大问题
#include <stdio.h>struct date
{
int year;
int month;
int day;
}st;
void f(int day);
void main()
{
struct date st;
enum weekday{sun,mon,tue,wed,thu,fri,sat}day;
//int i;
for(day=sun;day<=sat;day++)
printf("%d",day);
}
printf("plase input year:");
scanf("%d",&st.year);
printf("plase input month:");
scanf("%d",&st.month);
printf("plase input day:");
scanf("%d",&st.day);
if(st.month==1||st.month==2)
{
st.month+=12;
st.year--;
}
day=(enum weekday)(st.day+2*st.month+3*(st.month+1)/5+st.year+st.year/4-st.year/100+st.year/400)%7;
f(day);
}
void f(day)
{
switch(day)
{
case(0):printf("星期一\n");break;
case(1):printf("星期二\n");break;
case(2):printf("星期三\n");break;
case(3):printf("星期四\n");break;
case(4):printf("星期五\n");break;
case(5):printf("星期六\n");break;
case sun:printf("星期日\n");break;
}
}
怎么让case 里面的是sun,而不是6呢