Programming code | C + + / C output Gregorian calendar – beautiful calendar production

Time:2021-1-15

Preface: This article introduces how to use C language code to realize the use of perpetual calendar examples, application skills, summary of basic knowledge points and matters needing attention. It has a certain reference value, and friends who need it can refer to it.

 

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

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

{
Intr = 1, z = R, NN = year, YY = month;
NN = year, YY = month;
When (NN) if (- – YY) Z + = return the days of the month (NN, YY); else — NN, YY = 13;
NN = days of return month (year, month); YY = 1;

Cout < < year < < year < < month < < month < < day < < day today, week < < (Z + day – 1)% 7 < < “< n Sunday / T Monday / T Tuesday / T Wednesday / T Thursday / T Friday / T Saturday / n.”;
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.wDay );

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

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

 

{
Intr = 1, z = R, NN = year, YY = month; string AA = {day “,” one “,” two “,” three “,” four “,” Five “,” six “};
NN = year, YY = month;
When (NN) if (- – YY) Z + = return the days of the month (NN, YY); else — NN, YY = 13;
NN = days of return month (year, month); YY = 1;
Cout < < year < < year < < month < < month < < day < < day today, week < < AA [(Z + day – 1)% 7] < < n day / day / day;
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;
}

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

Staticint returns the number of days in the month (INTN, inty)
{/ / reasons https://bbs.csdn.net/topics/395074486
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));
}
Static void output calendar (int year, int month, int day)
{
Intr = 1, z = R, NN = year, YY = month; string AA = {day “,” one “,” two “,” three “,” four “,” Five “,” six “};
NN = year, YY = month;

When (NN > 0) if (- – YY > 0) Z + = return the number of days in the month (NN, YY); else {– NN; YY = 13;}
NN = days of return month (year, month); YY = 1; Z% = 7;
Console.Write (“{0} year {1} month {2} day today {3} day {1} day {2} day {3} day {1} day {2} day {2} day {3} day {4} day {4} day {5} day {6} day {(Z + day – 1)% 7];
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”));
}
Output calendar( DateTime.Now.Year , DateTime.Now.Month , DateTime.Now.Day ); Console.WriteLine ;

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

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

{
Intr = 1, z = R, NN = year, YY = month; string s = day 123456;
When (NN) if (- – YY) Z + = return the days of the month (NN, YY); else — NN, YY = 13;
NN = days of return month (year, month); YY = (Z + day – 1)% 7 * 2;
Cout < year < year < month < month < day < day < ends < week; cout.put (s[yy]).put(s[yy + 1]) << endl;
Cout < < days < < ends < < one < < ends < < two < < ends < < three < < ends < < four < < ends < < five < < ends < < six;
yy = 0;
while(r <= nn)
if(yy >= (z %= 7))

 

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

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;
}

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

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

{
Intr = 1, z = R, NN = year, YY = month;
String week = {“day”, “one”, “two”, “three”, “four”, “Five”, “six”};
When (NN) if (- – YY) Z + = return the days of the month (NN, YY); else — NN, YY = 13;
NN = days of return month (year, month); YY = 0;
Cout < < year < < year < (month > 9? “:” 0 “) < month < < month < < day > 9?”: “0”) < day < < day week < < week [(Z + day – 1)% 7] < 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;

Programming code | C + + / C output Gregorian calendar - beautiful calendar production

 

usingSystem.Globalization ; / / lunar calendar
Staticstring monthly calendar loading
{
System.Globalization.ChineseLunisolarCalendar Microsoft lunar calendar= newSystem.Globalization.ChineseLunisolarCalendar ;
Int day = Microsoft lunar calendar. Getdayofmonth (newdatetime)( DateTime.Now.Year , DateTime.Now.Month , DateTime.Now.Day )
Month = Microsoft lunar calendar. Getmonth (newdatetime)( DateTime.Now.Year , DateTime.Now.Month , DateTime.Now.Day )
Year = Microsoft lunar calendar.getsexagenaryyear( DateTime.Now );
Return “lunar calendar” + “a, B, C, D, e, G, Xin, Ren, GUI” [Microsoft lunar calendar. Getcelesticalstem (year)]
+”Mouse, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, chicken, dog, pig” + “year”
+”The first month of the month” + (“ten twenty three” [days / 10]) ToString.Replace (“,” + “123456789” [day% 10];
}

 

Static void output calendar (int year, int month, int day)
{
Intr = 1, z = R, NN = year, YY = month; string AA = “:”;
FuncZero padding = (int data) = > {return (Data > 9? “:” 0 “);};
When (NN > 0) if (- – YY > 0) Z + = return the number of days in the month (NN, YY); else {– NN; YY = 13;}
NN = days of return month (year, month); YY = 1; Z% = 7;
/ / Console.WriteLine (“{0}”, monthly calendar loading);
Console.Write (“{0} year” + zeroing (month) + “{1} month” + zeroing (day) + “{2} day week {3} {4} day 123456 (n::”, year, month, day, “day 123456” [(Z + day – 1)% 7], month calendar loading (year, month, day));
while(r <= nn)
if(yy >= z)
{
If (r < = days of return month (year, month)) AA + = monthly calendar load (year, month, R). Substring (8, 2) + ((+ + YY% 7) > 0? “” ‘”;”;
Console.Write (“{0} {1} {2}”, zero complement (R), (R + +). ToString, ((YY% 7) > 0? “:));
if(aa.Contains(“\n”)) { Console.Write(“{0}”, aa = aa.Replace(” “, ” “)); aa = ” “; }
}
else
{
If (r < = days of return month (year, month)) AA + = (r > 1? Monthly calendar load (year, month, R). Substring (8, 2): “:”) + ((YY% 7) > 0? “” “‘”‘ “, ‘(n));
Console.Write (“{0} {1} {2}”, (r > 1? Complement zeros (R): “, (r > 1? (R + +). ToString::”, ((+ + YY% 7) > 0? “:”, ((+ + YY% 7))));
if(aa.Contains(“\n”)) { Console.Write(“{0}”, aa = aa.Replace(” “, ” “)); aa = ” “; }
}
}
Total stopwatch running time= Stopwatch.StartNew ;
Console.WriteLine (“- ntime: {0} cycle ends. “, total running time. Elassedticks);

Recommended Today

Practice of query operation of database table (Experiment 3)

Following the previous two experiments, this experiment is to master the use of select statements for various query operations: single table query, multi table connection and query, nested query, set query, to consolidate the database query operation.Now follow Xiaobian to practice together!Based on the data table (student, course, SC, teacher, TC) created and inserted in […]