如题所述
第1个回答 2015-09-26
#include <stdio.h>
int main()
{
int mouth,day,i,n;
printf("请输入本年1月1日是星期几(星期日请输入7):");
scanf("%d",&n);
while(1)
{
day=n;
printf("请输入要查看的月份:");
scanf("%d",&mouth);
switch (mouth)
{
case 1:break;
case 2:if(day<=4)day+=3;else day-=4;break;
case 3:if(day<=4)day+=3;else day-=4;break;
case 4:if(day<=1)day+=6;else day-=1;break;
case 5:if(day<=6)day+=1;else day-=6;break;
case 6:if(day<=3)day+=4;else day-=3;break;
case 7:if(day<=1)day+=6;else day-=1;break;
case 8:if(day<=5)day+=2;else day-=5;break;
case 9:if(day<=2)day+=5;else day-=2;break;
case 10:break;
case 11:if(day<=4)day+=3;else day-=4;break;
case 12:if(day<=2)day+=5;else day-=2;break;
}
printf("MON TUE WED THU FRI SAT SUN\n");
if(mouth==1||mouth==3||mouth==5||mouth==7||mouth==8||mouth==10||mouth==12)
{
for(i=0;i<day+30;i++)
{
if(i<day-1)
printf(" ");
else
printf("%-5d",i-day+2);
if((i+1)%7==0)
printf("\n");
}
printf("\n");
}
else if(mouth==2)
{
for(i=0;i<day+27;i++)
{
if(i<day-1)
printf(" ");
else
printf("%-5d",i-day+2);
if((i+1)%7==0)
printf("\n");
}
printf("\n");
}
else
{
for(i=0;i<day+29;i++)
{
if(i<day-1)
printf(" ");
else
printf("%-5d",i-day+2);
if((i+1)%7==0)
printf("\n");
}
printf("\n");
}
}
return 0;
}追问
好的好的谢谢~
你还没回答吧
呵呵