C语言程序编写日历

C语言程序编写日历,第1张

/*你好,这个问题我来回答,希望能被采纳:*//*函数功能输出year的日历*/#include<stdio.h>void

main(){int

a,b,c,d,e,f,i,j,k,n,m,yearprintf("input

the

year:\n")

scanf("%d",&year)

//输入数据的初始化;b=yearc=year%4d=year/4e=d*1461+c*365f=e%7j=f

//初始化Year年的第一天的星期m=jprintf("***%d年的日历***\n",year)for(a=1a<=12a++)

//函数的主要部分,主要实现日历的打印部分

{

if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)k=31

else

if(a==4||a==6||a==9||a==11)k=30

else

if((year%4==0&&year%100!=0)||(year%400==0))k=29

else

k=28

printf("%d月份\n

STAT

SUN

MON

TUE

WED

THUR

FRI\n",a)

m=j

if(m<=5)m=m+1

else

m=m-6

for(n=1n<=mn++)printf("

")

for(i=1i<=ki++,j++)

{if(j==7)j=0

if(i<10)printf("

%d",i)

else

printf("

%d",i)

if(j==5)printf("\n")

}

printf("\n\n\n")

}}

#include \x0d\x0avoid main() \x0d\x0a{ \x0d\x0aint i,j,k,year,week\x0d\x0aint day[]={31,28,31,30,31,30,31,31,30,31,30,31}\x0d\x0achar month[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"}\x0d\x0a\x0d\x0aprintf("Input year you want to print:")\x0d\x0ascanf("%d",&year)\x0d\x0a\x0d\x0aif((year%4==0&&year%100!=0)||(year%400==0)) day[1]++//判断是否闰年\x0d\x0aweek=(35+year+year/4-year/100+year/400)%7//计算当年的1月1日是周几的公式 \x0d\x0a\x0d\x0afor(i=0i=7) \x0d\x0a{ \x0d\x0aprintf("\n")\x0d\x0aweek=week%7\x0d\x0a} \x0d\x0a} \x0d\x0aprintf("\n")\x0d\x0a} \x0d\x0a}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11224387.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存