Introduction: This article introduces how to use C language code to achieve perpetual calendar use examples, application skills, basic knowledge summary and need to pay attention to matters, has a certain reference value, need friends can refer to.

Void output calendar (int year, int month, int day)

{intr = 1, z = r, nn = year, yy = month; Nn = years; Yy = month; While (nn)if(–yy)z += return the number of days of the month (nn, yy); else–nn, yy = 13; Nn = return number of days of month (year, month); yy = 1;

Cout < < < < years “in” < < < < month “month” < < < < day “, what day is it today “< < (z + 1) % 7 < <” \ t \ n \ t on Sunday Monday Tuesday \ t \ \ t t Wednesday Thursday Friday Saturday \ \ t n. \ t “; while(r <= nn) if(yy >= (z %= 7)) cout << (r > 9 ? “”: “0”) << r++ << ((++yy % 7) ? “\t”: “\t\n”); else cout << (r > 1 && r <= 9 ? “0”: “”) << (r > 1 ? to_string(r++) : “.”) << ((++yy % 7) ? “\t”: “\t\n”); cout << endl; }

#include

CTime time(CTime::GetCurrentTime); SYSTEMTIME timeDest; time.GetAsSystemTime(timeDest); Output calendar (timeDest. WYear, timeDest. WMonth, timeDest.

Void output calendar (int year, int month, int day)

{intr = 1, z = r, nn = year, yy = month; String aa = {” day “, “a”, “2”, “three”, “four”, “five”, “six”}; Nn = years; Yy = month; While (nn)if(–yy)z += return the number of days of the month (nn, yy); else–nn, yy = 13; Nn = return number of days of month (year, month); yy = 1; Cout < < < < years “in” < < < < month “month” < < < < day “, what day is it today “< < aa [7] (z + 1) % < <” \ t \ n, a \ \ t two three four \ \ t t t 5 to 6 \ \ t n. \ t “; while(r <= nn)

if(yy >= (z %= 7))

cout << (r > 9 ? “”: “0”) << r++ << ((++yy % 7) ? “\t”: “\t\n”);

else

cout << (r > 1 && r <= 9 ? “0”: “”) << (r > 1 ? to_string(r++) : “.”) << ((++yy % 7) ? “\t”: “\t\n”);

cout << endl;

}

Staticint Number of days returned in a month (intN, intY) {// cause bbs.csdn.net/topics/3950… return(Y == 2 ? (((((N % 4) == 0 && (N % 100) > 0) || (N % 400) == 0) ? true: false) ? 29 : 28) : (((Y <= 7 && (Y % 2) > 0) || (Y > 7 && (Y % 2) == 0)) ? 31:30)); } staticvoid staticvoid intr = 1, z = r, nn = year, yy = month; String aa = {” day “, “a”, “2”, “three”, “four”, “five”, “six”}; Nn = years; Yy = month;

While (nn > 0) if(–yy > 0) z += return the number of days of the month (nn, yy); else{ –nn; yy = 13; } nn = return number of days of month (year, month); yy = 1; z %= 7; Console. Write (” {0} on {1} {2} {3} \ \ t n day today week one \ t two three \ \ t t four five six \ t \ n \ t: : \ t “, year, month, day, day 123456 “[7] (z + 1) %). while(r <= nn) if(yy >= z) Console.Write(“{0}{1}{2}”, (r > 9 ? “”: “0”), (r++).ToString, ((++yy % 7) > 0 ? “\t”: “\t\n”)); else Console.Write(“{0}{1}{2}”, (r > 1 && r <= 9 ? “0”: “”), (r > 1 ? (r++).ToString : “::”), ((++yy % 7) > 0 ? “\t”: “\t\n”)); Year, datetime.now. Month, datetime.now. Day; Console.WriteLine;

Void output calendar (int year, int month, int day)

{intr = 1, z = r, nn = year, yy = month; String s = “day 1, 2, 3, 4, 5, 6 “; While (nn)if(–yy)z += return the number of days of the month (nn, yy); else–nn, yy = 13; Nn = return number of days of month (year, month); Yy = (z + d – 1) % 7 * 2; Cout < < < < years “in” < < < < month “month” < < < < day “, “< < < < ends” week “. cout.put(s[yy]).put(s[yy + 1]) << endl; Cout < < “, “< < ends < <” “< < ends < <” “< < ends < < < < ends” three “< < < < ends” four “< < < < ends” five “< <” six “; yy = 0; while(r <= nn) if(yy >= (z %= 7))

if(! (yy++ % 7))cout << endl << (r > 9 ? “”: “0”) << r++ << ends; elsecout << (r > 9 ? “”: “0”) << r++ << ends; else if(! (yy++ % 7))cout << endl << “::”<< ends; elsecout << (r > 1 && r <= 9 ? “0”: “”) << (r > 1 ? to_string(r++) : “::”) << ends; cout << endl; }

Void output calendar (int year, int month, int day)

{intr = 1, z = r, nn = year, yy = month; String week = {” day “, “a”, “2”, “three”, “four”, “five”, “six”}; While (nn)if(–yy)z += return the number of days of the month (nn, yy); else–nn, yy = 13; Nn = return number of days of month (year, month); yy = 0; Cout << year << “year “<< (month > 9? “”: “0”) << month << month << (day > 9? “” :” 0 “), < < < < “day of week” < < week [7] (z + 1) % < < endl; While (yy < 7)cout << week [yy++] << ends; yy = 0; while(r <= nn) if(yy >= (z %= 7)) if(! (yy++ % 7))cout << endl << (r > 9 ? “”: “0”) << r++ << ends; elsecout << (r > 9 ? “”: “0”) << r++ << ends; else if(! (yy++ % 7))cout << endl << “::”<< ends; elsecout << (r > 1 && r <= 9 ? “0”: “”) << (r > 1 ? to_string(r++) : “::”) << ends; cout << endl;

usingSystem.Globalization; / / loading {staticstring lunar calendar System. Globalization. ChineseLunisolarCalendar Microsoft lunar = newSystem.Globalization.ChineseLunisolarCalendar; Int day = Microsoft lunar calendar. GetDayOfMonth(newDateTime(datetime.now. Year, datetime.now. Month, datetime.now. Day)), Month = Microsoft lunar calendar. Month(newDateTime(datetime.now. Year, datetime.now. Month, datetime.now. Day)), Year = Microsoft Lunar calendar. GetSexagenaryYear(DateTime.Now); Return “calendar: “+” GetCelestialStem(year)

  • Restrialbranch (year) + “year”
  • “Are two three four five six seven eight nine ten winter la “[month] + (day > 10? “Month” : “early”) + (10 to 20 “sa” [10] / day). The ToString. Replace (” “, “”) +” 123456789 “[10] % day;

}

Staticvoid output calendar (int year, int month, int day) {intr = 1, z = r, nn = year, yy = month; staticvoid output calendar (int year, int month, int day) {intr = 1, z = r, nn = year, yy = month; string aa = ” :::: “; Func

add zero = (int data) => {return(data > 9? “” :” 0 “); }; While (nn > 0) if(–yy > 0) z += return the number of days of the month (nn, yy); else{ –nn; yy = 13; } nn = return number of days of month (year, month); yy = 1; z %= 7; // console. WriteLine(“{0}”, calendar load); In the Console. Write (” {0} “+ zero padding () +” {1} month + complement “zero () +” week {3} {2}, {4} \ n days The 12345 six \ n… “Year, month, day,” as soon as the 23456 “[7] (z + 1) %, calendar load (year, month, day)); While (r < = nn) if (yy) > = z {the if (r < = back on the number of days (year, month)) aa + = calendar load (year, month, r). The Substring (8, 2) + (> 0 + yy % (+ 7)? ” “: ” \n”); The Console. Write (” {0} {1} {2} “, zero padding (r), (r++). ToString, (% 7 (yy) > 0? “” :” “)); if(aa.Contains(“\n”)) { Console.Write(“{0}”, aa = aa.Replace(” “, ” “)); aa = ” “; }} else {if(r <= month) aa += (r > 1? Calendar load (year, month, r). The Substring (8, 2) : “:”) + (% 7 (yy) > 0? ” “: ” \n”); Console.Write(“{0}{1}{2}”, (r > 1 ? “), (r > 1? (r++).ToString : “::”), ((++yy % 7) > 0 ? ” “: ” \n”)); if(aa.Contains(“\n”)) { Console.Write(“{0}”, aa = aa.Replace(” “, ” “)); aa = ” “; }}} Stopwatch total running time = stopwatch.startNew; Console.WriteLine(“\n Time: {0} end of cycle.” , total running time. ElapsedTicks);
,>