发布网友 发布时间:2022-04-24 04:30
共2个回答
热心网友 时间:2023-09-09 14:14
万年历流程图1800年到2100年中我输入任意一天可以得到下一天的年月日!
#include <stdio.h>
int leap (int year)
{if(year%4==0&&year%100!=0||year%400==0) <br/>return 1; <br/>else return 0; <br/>}
int days_month (int month,int year)
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
return 31;
if(month==4||month==6||month==9||month==11)
return 30;
if(month==2&&leap(year)==1) return 29;
else return 28;
}
int firstday(int month,int year)
{int w; <br/>w=(1+2*month+3*(month+1)/5+year+year/4+year/400-year/100)%7+1; <br/>return w; <br/>}
main()
{int i,j=1,k=1,a,b,month,year; <br/>printf("\n input month and year:\n"); <br/>scanf("%d%d",&month,&year); <br/>b=days_month(month,year); <br/>a=firstday (month,year); <br/>printf(" Sun Mon Tue Wed Thu Fri Sat \n"); <br/>if(a==7) <br/>{for(i=1;i<=b;i++) <br/>{printf("%4d",i); <br/>if(i%7==0) <br/>{printf("\n"); <br/>}
}
}
if(a!=7)
{while (j<=4*a) <br/>{printf(" "); <br/>j++; <br/>}
for(i=1;i<=b;i++)
{printf("%4d",i); <br/>if(i==7*k-a) <br/>{printf("\n"); <br/>k++; <br/>}
}
}
getch();
热心网友 时间:2023-09-09 14:15
费劲``