当前位置: 代码迷 >> C语言 >> 想把日历改为左右个六个输出
  详细解决方案

想把日历改为左右个六个输出

热度:110   发布时间:2007-11-06 12:47:33.0
想把日历改为左右个六个输出
想把日历改为左右个六个输出.现在的代码是向下输出12个月:
#include<stdio.h>
void main(void)
{ int b[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int year,month,know=1950;
int i,j,k,l,m,n;
printf("Please input the year whose calendar you want to know :");
scanf("%d",&year);
printf("The Calendar of Year %d",year);
printf("\n");
k=year-know;
l=k%4;
m=k/4;
if(l==0) l=(5*m)%7;
else if (l==1) l=(1+5*m)%7;
else if(l==2) l=(2+5*m)%7;
else l=(4+5*m)%7;
if(l==2) b[2]=29;
for(month=1;month<=12;month++)
{

printf("%d",month);
printf(" Sun Mon Tue Wen Tur Fri Sat \n");
if(month!=1) l=(b[month-1]+l) %7;
else l=l;
for(j=0;j<l;j++)
{ putchar(' ');
putchar(' ');
putchar(' ');
putchar(' ');
}
n=1;
for(i=l;i<b[month]+l;i++)
{ printf("%4d",n);
n++;
if(i%7==6) printf("\n");
}
printf("\n");
if(month==1) getchar();
}

}
搜索更多相关的解决方案: 日历  输出  

----------------解决方案--------------------------------------------------------

bd
----------------解决方案--------------------------------------------------------
  相关解决方案