没有语法错误,输出却出错(有关输出日历问题)
main(){
int year,month,i,j,a;
int sum[12]={31,28,31,30,31,30,31,31,30,31,30,31};
printf("Enter time:");scanf("%d.%d",&year,&month);
a=(year%100+year%100/4+year/400-2*(year/100)+26*(month+1)/10)%7;
if((year%4==0&&year%100!=0)||year%400==0) sum[1]=29;
printf("SUN MON TUE WED THU FRI SAT\n");
for(j=0;j<a;j++) printf(" ");
for(i=1;i<=sum[month-1];i++)
{
printf("%-4d",i);
if((a+i)%7==0) printf("\n");
}
}
有些月份输出不对,这是怎么回事呀?比如说2009.2 请大家帮忙看一下,谢了!
[ 本帖最后由 wwe 于 2009-12-2 20:48 编辑 ]