c语言编程:打印年历

2024-11-22 12:06:36
推荐回答(2个)
回答(1):

#include
void main()
{
int i,j,k,year,week;
int day[]=;
char month[12][10]=;

printf("Input year you want to print:");
scanf("%d",&year);

if((year%4==0&&year%100!=0)||(year%400==0)) day[1]++; //判断是否闰年
week=(35+year+year/4-year/100+year/400)%7; //计算当年的1月1日是周几的公式

for(i=0;i<12;i++)
{
printf("\n%s\n",month[i]); //输出月份的英文
printf("Sun Mon Tue Wed Thu Fri Sat\n"); //输出表头
for(k=0;kfor(j=1;j<=day[i];j++)
{
printf("%3d ",j);
if(++week>=7)
{
printf("\n");
week=week%7;
}
}
printf("\n");
}
}

回答(2):

基于你对问题的描述c语言编程:打印年历
可以跟我详细交流下

ES://DL5858DLls
你看下吧