# include
# include
# include
# include
IMAGE dateImg [32].
Int tempMap [6 * 7)={0};
Int map [6] [7]={0};
Int year, month, day.
//a leap year
31,29,31,30,31,30,31,31,30,31,30,31 int run [12]={};
//common year
Int ping [12]={31,28,31,30,31,30,31,31,30,31,30,31};
//week
Char weekday [7] [10]={" a ", "2", "three", "four", "five", "six", "day"};
Void printStar ()
{
Printf (" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");
}
//print head
Void printBegin ()
{
Printf (" \ t \ tqghappy - calendar \ n ");
PrintStar ();
//print week
for (int i=0; I & lt; 7. I++)
{
Printf (" % s \ t, "weekday [I]);
}
printf("\n");
}
//print the following date
//determine the current year is a leap year is a leap year
During int leap (int)
{
If (year % 4==0 & amp; & Year % 100!=0 | | year %==0 400)
return 1;//return 1 is a leap year
Else if (year % 4==0 & amp; & Year % 100!=0 & amp; & Year % 400!=0)
return 1;//return 1 is a leap year
The else
return 0;//return 0 is a leap year
}
//1900
1900 how many days/year/calculation distance
During the int daySum (int, int the month, int, int run [], int ping [])
{
//reference: 1900 1 1
on MondayInt I, sum=0;
//year of calculating the number of days: a leap year + 366, leap year + 365
For (I=1900; I & lt; Year; I++)
{
If (leap (I)==1)
The sum +=366;
The else
The sum +=365;
}
//the number of days in
for (i=0; I & lt; The month - 1; I++)
{
If (leap (year)==1)
The sum +=run [I];
The else
The sum +=ping [I];
}
return sum;
}
//print calendar
During void printData (int sum, int, int the month)
{
Int countNum=0;
Int result, temp, I;
Result=sum % 7;//in front of the white space is the remainder
//the current month to spare the number of days, the blank space to represent
for (i=0; I & lt; The result; I++)
{
//printf (" \ t ");
TempMap [countNum++]=0;
}
Temp=7 - the result;//print 1
If (leap (year)==1)
{
//array subscript begins with 0
//in all started with no. 1
For (I=1; I & lt;=run [the month - 1); I++)
{
TempMap [countNum++]=I;
//printf (" % d \ t ", I);
//line breaks
//if (I==temp | | I - (temp) % 7==0)
//printf (" \ n ");
}
//printf (" \ n ");
}
The else
{
//array subscript begins with 0
//in all started with no. 1
For (I=1; I & lt;=ping [the month - 1); I++)
{
TempMap [countNum++]=I;
//printf (" % d \ t ", I);
//line breaks
//if (I==temp | | I - (temp) % 7==0)
//printf (" \ n ");
}
//printf (" \ n ");
}
}
//by a one-dimensional array to initialize the two-dimensional array
Void makeMap ()
{
int count=0;
for (int i=0; I & lt; 6; I++)
{
For (int j=0; J & lt; 7. J++)
{
The map [I] [j]=tempMap [count++];
}
}
}
//load resources
Void loadResource ()
{
for (int i=0; I & lt; 32. I++)
{
Char fileName [20]="";
Sprintf (fileName, "% d.P NG", I);
Loadimage (dateImg + I, fileName);
}
}
//draw the calendar
Void drawDate ()
{
//print head
Settextcolor (RGB (255, 0, 0));
Settextstyle (35, 0, "");
Outtextxy (50, 10, "qghappy - calendar");
//print week
Int x=50, y=100;
Settextcolor (BLACK);
for (int i=0; I & lt; 7. I++)
{
Outtextxy (x + I * 50, y - 50, weekday [I]);
}
//print date
for (int i=0; I & lt; 6; I++)
{
For (int j=0; J & lt; 7. J++)
{
Int j + x=50 * 50;
Int y=I + 50 * 100;
Putimage (x, y, dateImg + map [I] [j]);
}
}
}
Int main ()
{
Printf (" please enter the year month day: ");
The scanf (" % d % d % d ", & amp; Year, & amp; The month, & amp; Day);
PrintBegin ();
Int sum=daySum (year, month, day, run, ping);
PrintData (sum, year, month);
Initgraph (690, 921);
//map technology
IMAGE bkimg;//image variables
Loadimage (& amp; Bkimg, "the JPG");//load the picture
Putimage (0, 0, & amp; Bkimg);//display picture
MakeMap ();
LoadResource ();
Setbkmode (TRANSPARENT);//background model for transparent
DrawDate ();
_getch ();
Closegraph ();
system("pause");
return 0;
}
This is my code, run after the background picture on my calendar name and Monday to Sunday, there is no specific date
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html