void main()
{
Printf ("This program finds the day of the week and prints this year's almanac. If it is illegal entry, it will automatically exit: \ n ");
Printf ("Please enter the year, month and day:");
while( 1)
{
Cycle:
// printf ("Please enter the year, month and day:");
int o,p,q;
Qi Xing, Italy, Mexico, Netherlands, China;
scanf("%d%d%d ",& ampo & amp; p & amp; q); //Parameter corresponds to year, month and day.
If (o<0 || p>12 ||| p <; 0 ||| Q<0 || Q>31)/Illegal input judgment
{
Printf ("Illegal input, please press any key to exit \ n"); //Illegal exit
Break;
}
y = o;
m = p;
d = q;
if(m== 1||m==2)
m = m+ 12;
If (m> 12)
y = y- 1;
YY = y % 100;
c =(y/ 100);
w = YY+(YY/4)+(c/4)-2 * c+(26 *(m+ 1)/ 10)+d- 1; //Weekly calculation
Qi Xing = w% 7;;
If (Qi Xing & lt0)
Qi Xing = 7+ Qi Xing; //week correction
If (Qi Xing ==0) printf ("Today is Sunday \ n"); //Print the week
If (Qi Xing == 1) printf ("Today is Monday \ n");
If (Qi Xing ==2) printf ("Today is Tuesday \ n");
If (Qi Xing ==3) printf ("Today is Wednesday \ n");
If (Qi Xing ==4) printf ("Today is Thursday \ n");
If (Qi Xing ==5) printf ("Today is Friday \ n");
If (Qi Xing ==6) printf ("Today is Saturday \ n");
//printf ("Press any key to continue: \ n");
//if((n = getchar())= ' \ n ')break;
//goto loop;
//Return ();
//printf(" erro ");
Int uu// sentence
if((y % 4 = = 0 & amp; & ampy% 100! =0)||y%400==0) // Off
uu = 1; //leap
Otherwise//year
uu = 0;
If(uu== 1) //
Printf("%d is a leap year: \n ",y); //print
Else // Yes
Printf("%d year is not a leap year \n ",y); //No.
//leap year
Printf("%d calendar is printed as follows: \n ",y); //Print the almanac
int i,j,k,PP;
for(I = 1; I< 13; i++)
{
If (I = =1|||| I = = 3 ||| I = = 5 ||||| I = = 7 ||||| I = = 8 |||||| I = =10 |||| I = =12.
{printf("\n %d month: \n\n ",I);
printf(" Day 123456 \ n ");
printf(" "); //20 spaces
PP =(YY+(YY/4)+(c/4)-2 * c+(26 *(I+ 1)/ 10))% 7; //Calculate a day in a month, 1.
if(PP & lt; 0)
PP = 7+PP;
for(j = 0; J<6 * ppj++)/1is empty.
printf(" ");
for(j = 1; j & lt32; j++)
{
printf("%-6d ",j); //%-6d left-aligned.
if((pp+j)%7==0)
{//line break judgment
printf(" \ n ");
printf(" \ n ");
printf(" "); //Spaces before career change
}
}
}
If (I = = 4 |||| I = = 6 |||| I = = 9 ||| I = =11)/Print the middle month.
{printf("\n %d month: \n\n ",I);
printf(" Day 123456 \ n ");
printf(" ");
PP =(YY+(YY/4)+(c/4)-2 * c+(26 *(I+ 1)/ 10))% 7;
if(PP & lt; 0)
PP = 7+PP;
for(j = 0; j & lt6 * ppj++)
printf(" ");
for(j = 1; j & lt3 1; j++)
{
printf("%-6d ",j);
if((pp+j)%7==0)
{
printf(" \ n ");
printf(" \ n ");
printf(" ");
}
}
}
If(i==2) // Print the flat month.
{printf("\n %d month: \n\n ",I);
printf(" Day 123456 \ n ");
printf(" ");
PP =(YY+(YY/4)+(c/4)-2 * c+(26 *(I+ 1)/ 10))% 7;
if(PP & lt; 0)
PP = 7+PP;
for(j = 0; j & lt6 * ppj++)
printf(" ");
if(uu== 1)
for(j = 1; j & lt30; j++)
{
printf("%-6d ",j);
if((pp+j)%7==0)
{
printf(" \ n ");
printf(" \ n ");
printf(" ");
}
}
If (uu==0)
for(j = 1; j & lt29; j++)
{
printf("%-6d ",j);
if((pp+j)%7==0)
{
printf(" \ n ");
printf(" \ n ");
printf(" ");
}
}
}
printf(" \ n "); //Line feed after printing every month.
}
printf(" \ n ");
//printf ("Press any key to continue: \ n");
Printf ("Please enter the year, month and day to continue:");
Go to loop;
//system(" PUUSE ");
}
}