求C语言“打印日历”程序!!!!!
答案:1 悬赏:0 手机版
解决时间 2021-03-26 17:58
- 提问者网友:浩歌待明月
- 2021-03-25 22:49
求C语言“打印日历”程序!!!!!
最佳答案
- 五星知识达人网友:神鬼未生
- 2021-03-25 23:59
#include
void main()
{
int i,j,k,year,week;
int day[]={31,28,31,30,31,30,31,31,30,31,30,31};
char month[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"};
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;k for(j=1;j<=day[i];j++)
{
printf("%3d ",j);
if(++week>=7)
{
printf("\n");
week=week%7;
}
}
printf("\n");
}
}
void main()
{
int i,j,k,year,week;
int day[]={31,28,31,30,31,30,31,31,30,31,30,31};
char month[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"};
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;k
{
printf("%3d ",j);
if(++week>=7)
{
printf("\n");
week=week%7;
}
}
printf("\n");
}
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯