C语言程序 万年历编程
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
{if (a%100==0)
{if (a%400==0)
ya=1;
}
else ya=1;
}
else ya=0;
}
if (ya==1||b==2)
c=28;
else c=29;
switch (b)
{
case 1:case 3:case 5:case 7:case 8:case 12:c=31;break;
case 2:x=29;break;
case 4: case 6: case 9: case 10: case 11:x=30;break;
}
wa=week(y,a,1);
if (wa=="星期日") j=0;
else if (wa=="星期一") j=1;
else if (wa=="星期二") j=2;
#include<math.h>
#include<stdio.h>
//求某个日期对应的星期
char w[][7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
int i,j,m,d,y;
char week(int a,int b,int c) //定义星期函数
else if (wa=="星期三") j=3;
else if (wa=="星期四") j=4;
else if (wa=="星期五") j=5;
else if (wa=="星期六") j=6;
}
for (i=0;i<=5;i++)
{
for(;j<=7;j++)
{
if (xa<x)
{
int iweek;
if(b==1||b==2)
{
b+=12;
c--;
}
iweek=(c+2*b+3*(b+1)/5+a+a/4-a/100+a/400)%7;
switch(iweek)
{
case 0:printf("%s ",w[1]);break;
case 1:printf("%s ",w[2]);break;
{ xa++;
printf("%d",xa);
j=0;
}
}
printf("\n");
}
printf("\n");
}
{
int iweek;
if(b==1||b==2)
{
b+=12;
c--;
}
iweek=(c+2*b+3*(b+1)/5+a+a/4-a/100+a/400)%7;
switch(iweek)
{
case 0:printf("%s ",w[1]);break;
case 1:printf("%s ",w[2]);break;
case 2:x=28;break;
case 4: case 6: case 9: case 10: case 11:x=30;break;
}
else if (ya==0)
switch (a)
{
case 1: case 3: case 5: case 7: case 8: case 12:x=31;break;
}
return(w);
}
main()
{ //日历输出
scanf("%d",&y);
if (y%4==0)
{if (y%100==0)
{if (y%400==0) //判断月天数
1;
}
else ya=1;
}
else ya=0;
}
return(w);
}
main()
{
scanf("%d,%d,%d",&y,&m,&d);
printf("%s/n",week(y,m,d));
}
求某年某月有的天数
int day(int a,int b) //月天数函数
{
{
if (a%4==0)
for (a=1;a<=12;a++)
{
printf(" %d 月 \n",a);
for (i=0;i<7;i++) //输出星期
printf("%s ",w[i]);
printf("\n");
if (ya==1)
switch (a)
{
case 1: case 3: case 5: case 7: case 8: case 12:x=31;break;
case 2:printf("%s ",w[3]);break;
case 3:printf("%s ",w[4]);break;
case 4:printf("%s ",w[5]);break;
case 5:printf("%s ",w[6]);break;
case 6:printf("%s ",w[0]);break;
/*for (i=0;i<6;i++) 输出星期
printf("%s ",w[i]);*/
int a,i,j,y,ya,x,xa=0,b,c,m;
char w[][7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
char wa;
char week(int a,int b,int c) //定义星期函数
case 4:case 6:case 9:case 10:case 11:c=30;break;
}
return(c);
}
main()
{
scanf("%d,%d",&y,&m);
printf("%d天",day(y,m));
}
打印日历
#include<math.h>
#include<stdio.h>
case 2:printf("%s ",w[3]);break;
case 3:printf("%s ",w[4]);break;
case 4:printf("%s ",w[5]);break;
case 5:printf("%s ",w[6]);break;
case 6:printf("%s ",w[0]);break;
{if (a%400==0)
ya=1;
}
else ya=1;
}
else ya=0;
}
if (ya==1||b==2)
c=28;
else c=29;
switch (b)
{
case 1:case 3:case 5:case 7:case 8:case 12:c=31;break;
case 2:x=29;break;
case 4: case 6: case 9: case 10: case 11:x=30;break;
}
wa=week(y,a,1);
if (wa=="星期日") j=0;
else if (wa=="星期一") j=1;
else if (wa=="星期二") j=2;
#include<math.h>
#include<stdio.h>
//求某个日期对应的星期
char w[][7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
int i,j,m,d,y;
char week(int a,int b,int c) //定义星期函数
else if (wa=="星期三") j=3;
else if (wa=="星期四") j=4;
else if (wa=="星期五") j=5;
else if (wa=="星期六") j=6;
}
for (i=0;i<=5;i++)
{
for(;j<=7;j++)
{
if (xa<x)
{
int iweek;
if(b==1||b==2)
{
b+=12;
c--;
}
iweek=(c+2*b+3*(b+1)/5+a+a/4-a/100+a/400)%7;
switch(iweek)
{
case 0:printf("%s ",w[1]);break;
case 1:printf("%s ",w[2]);break;
{ xa++;
printf("%d",xa);
j=0;
}
}
printf("\n");
}
printf("\n");
}
{
int iweek;
if(b==1||b==2)
{
b+=12;
c--;
}
iweek=(c+2*b+3*(b+1)/5+a+a/4-a/100+a/400)%7;
switch(iweek)
{
case 0:printf("%s ",w[1]);break;
case 1:printf("%s ",w[2]);break;
case 2:x=28;break;
case 4: case 6: case 9: case 10: case 11:x=30;break;
}
else if (ya==0)
switch (a)
{
case 1: case 3: case 5: case 7: case 8: case 12:x=31;break;
}
return(w);
}
main()
{ //日历输出
scanf("%d",&y);
if (y%4==0)
{if (y%100==0)
{if (y%400==0) //判断月天数
1;
}
else ya=1;
}
else ya=0;
}
return(w);
}
main()
{
scanf("%d,%d,%d",&y,&m,&d);
printf("%s/n",week(y,m,d));
}
求某年某月有的天数
int day(int a,int b) //月天数函数
{
{
if (a%4==0)
for (a=1;a<=12;a++)
{
printf(" %d 月 \n",a);
for (i=0;i<7;i++) //输出星期
printf("%s ",w[i]);
printf("\n");
if (ya==1)
switch (a)
{
case 1: case 3: case 5: case 7: case 8: case 12:x=31;break;
case 2:printf("%s ",w[3]);break;
case 3:printf("%s ",w[4]);break;
case 4:printf("%s ",w[5]);break;
case 5:printf("%s ",w[6]);break;
case 6:printf("%s ",w[0]);break;
/*for (i=0;i<6;i++) 输出星期
printf("%s ",w[i]);*/
int a,i,j,y,ya,x,xa=0,b,c,m;
char w[][7]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"};
char wa;
char week(int a,int b,int c) //定义星期函数
case 4:case 6:case 9:case 10:case 11:c=30;break;
}
return(c);
}
main()
{
scanf("%d,%d",&y,&m);
printf("%d天",day(y,m));
}
打印日历
#include<math.h>
#include<stdio.h>
case 2:printf("%s ",w[3]);break;
case 3:printf("%s ",w[4]);break;
case 4:printf("%s ",w[5]);break;
case 5:printf("%s ",w[6]);break;
case 6:printf("%s ",w[0]);break;