#include <stdio.h>
#include <stdlib.h>
#include "tuisuan.h"
int y,year=1;
int main()
{
char name ;
printf ("\t********************\n");
printf ("\t* 欢迎使用 *\n");
printf ("\t********************\n");
printf ("Intput the year: ");
scanf ("%d",&y);
printf ("The calendar of the year %d.\n",y);
tuisuan(y,year);
return 0;
}
//2000.1.2 is sun.
#include <stdio.h>
extern int y,year;
static int m=1,d,dmax,w=3,s=2;
void tuisuan(int y,int year)
{
if (year<=y)
tuisuanOut (y,year);
else
tuisuanIng(y, year);
}
void tuisuanIng(int y,int year )
{
do
{
do
{ if (m==2)
if (y%4)
dmax=28;
else
dmax=29;
if (m==1||m==3||m==5||m==7||m==8||m==10||m==12)
dmax=31;
if (m==4||m==6||m==9||m==11)
dmax=30;
for (d=1;d<=dmax;d++)
{
w++;
if (w>=7)
w-=7;
s=w;
}
m++;
}while (m<=12);
year++;
}while (year<y);
}
/
void tuisuanOut(int y,int year)
{s++;
do
{ if (m==2)
if (y%4)
dmax=28;
else
dmax=29;
if (m==1||m==3||m==5||m==7||m==8||m==10||m==12)
dmax=31;
if (m==4||m==6||m==9||m==11)
dmax=30;
printf (" Sun Mon Tue Wed Thu Fri Sat\n");
for (;s>0;s--)
printf (" ");
for (d=1;d<=dmax;d++)
{
printf ("%4d",d);
w++;
if (w>=7)
{
printf ("\n");
w-=7;
}
s=w;
}
printf ("\n===========================\n");
m++;
}while (m<=12);
year++;
}