编程显示日历. 我已编好.请教如何写得简洁一点
# include <stdio.h># include <stdlib.h>
int main ()
{
int n,i,a;
printf("Enter number of days in month:");
scanf("%d",&n);
printf("Enter starting day of the week (1=Sun,7=Sat):");
scanf("%d",&a);
if (a==2)
printf(" ");
if (a==3)
printf(" ");
if (a==4)
printf(" ");
if (a==5)
printf(" ");
if (a==6)
printf(" ");
if (a==7)
printf(" ");
for ( i = 1 ; i<= n ; i++ ) {
if (i==(8-a)||i==(8-a+7)||i==(8-a+14)||i==(8-a+21)||i==(8-a+28))
printf("%3d\n",i);
else
printf("%3d ",i);
}
system("pause");
return 0;
}
用户指定这个月的天数和该月起始日是星期几
以上程序正确,我想请教一下有没更简便的做法
谢谢