Traditional Culture Encyclopedia - Almanac inquiry - Program yearbook
Program yearbook
# include & lttime.h & gt
# include & ltstdlib.h & gt
//Print the calendar of the current year and output it to the file name under the folder named after your student number.
Const char output file name! \n ",year, start _ year);
Return;
}
/* Check the entered month */
If (month & lt0 || month & gt 12)
{
Printf ("Illegal month: %d! The month must be within the range! \n ",year, start _ year);
Return;
}
/* * * * * * * * * * * * * * * * Start printing the calendar * * * * * * * * * * * * * * * *.
/* Calendar year title */
Printf ("calendar %d\n", year);
for(start month = 1; startMonth<= 12; start month+= showMonthNumPerLine)
{
showMonthNumPerLine =(start month+maxShowMonthNumPerLine)& lt; = 12 ? maxShowMonthNumPerLine:( 12-start month+ 1);
/* 1 beginning of calendar month */
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
printf("%-28s ",MONTH _ NAME[MONTH- 1]);
}
printf(" \ n ");
/* Week beginning of 2-year calendar */
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
for(I = 0; I<7; i++)
{
printf("%s ",WEEK _ NAME _ SHORT[I]);
}
printf(" ");
}
printf(" \ n ");
//dividing line
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
for(I = 0; I & lt4*7; i++)
{
printf(" _ ");
}
printf(" ");
}
printf(" \ n ");
/* data initialization */
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
//Week of the first day of each month
First day of monthinweekday [month-start month] = get first day of monthinweekday (year, month);
//Days of the month
Daysofmount [month-startmonth] = getDaysofmount (year, month);
//The number of days that have been output.
days counter[month-start month]=-first day ofmonthinweekday[month-start month]+ 1;
}
/* Arrange 3 calendars every day */
showMonthCounterPerLine = 0;
while(showMonthCounterPerLine & lt; showMonthNumPerLine)
{
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
for(I = 0; I<7; i++)
{
if(days counter[month-start month]& lt; = 0 | | days counter[month-start month]& gt; What day is it in a month?
{
printf("%4s "," ");
}
other
{
printf("%3d ",days counter[month-start month]);
}
days counter[month-start month]++;
if(days counter[month-start month]& gt; What day is it in a month?
{
showmonthcounterperline++;
}
}
printf(" ");
}
printf(" \ n ");
}
//dividing line
for(month = start month; Month & lt (startmonth+showmonthnumperline); Month++)
{
for(I = 0; I & lt4*7; i++)
{
printf(" _ ");
}
printf(" ");
}
printf(" \ n ");
}
}
int main(int argc,char *argv[])
{
Int year, month;
Time_t t = time (empty);
struct tm* now = localtime。 t);
Int selection;
/*
1
Displays a calendar of any year and month.
Output the almanac of the current year in a format of two months per line.
Output the almanac of any year in a format of two months per line.
*/
while( 1)
{
printf("××××××××××××××\ n ");
Printf(" 1 output the calendar of the current month1\ n ");
Printf("2 output current year almanac 2 \ n ");
Printf ("3Specify a calendar of any year and month 3 \ n");
Printf("4 specifies the calendar of any year 4 \ n ");
printf(" 5 exits 5 \ n ");
printf("××××××××××××××\ n ");
Scanf("%d ",& select);
Switch (selection)
{
Case 1:
PrintMonthCalendar (now->; Tm_year+ 1900, now-> TM _ mon+ 1);
Break;
Case 2:
PrintYearCalendar (now->; tm_year+ 1900,2);
Break;
Case 3:
Printf ("Enter year and month (yyyy-mm):");
Scanf("%d-%d ",& year & month);
PrintMonthCalendar (year, month);
Break;
Case 4:
Printf ("Enter year (YYYY):");:");
Scanf("%d-%d ",& year);
printYearCalendar(year,2);
Break;
Case 5:
Exit (0);
Default value:
Printf ("Wrong selection, please re-select \ n"); ;
};
}
Returns 0;
}
- Related articles
- Is it appropriate to buy fish on July 22, 2022?
- What is the most prosperous day for dogs to enter the house in 2022?
- In 2022, the zodiac is a rabbit. When is the best date to pick up the car in December of the lunar calendar?
- Gregorian calendar Old Gregorian calendar 1932
- Classical Chinese "Yue Fei learns to shoot"
- Who breached the Yuan Dynasty?
- 65438+ 10 opening day.
- Zodiac mouse almanac query
- What are the best auspicious days for burning incense from June 5438 to February 2022?
- Huangli precision floating tower