The original originated in 2012.1.10#include "stdio.h" #include "conio.h" #include "time.h" #include "stdlib.h" void Diao (int year,int month);// The first called function, just obtains space;int Leap (int year),//is a leap year plus 1int jjmonth (int year,int month),//calculates the total number of days of n months void Shuchu (int space,int year, int month);//output int get_leap (int year);//Determine if the leap year is int month_of_day (int year, int month);//A few days this month AH int main () {int year,month; int Kongzhi; struct TM*P;//TM struct pointer time_t secs;//declares the time_t type variable time (&secs);//Gets the system date and time P=localtime (&secs);//Get local datetime date printf ("\ n now:%d-%d-%d%d:%d:%d week%d \ n", P->tm_mon+1,p->tm_mday,p->tm _year+1900,p->tm_hour,p->tm_min,p->tm_sec,p->tm_wday); year=p->tm_year+1900;month=p->tm_mon+1; Diao (Year,month); while (1) {kongzhi=getch ();//Getch you don't have to press ENTER if (kongzhi== ' W ') year=year+1; if (kongzhi== ' s ') year=year-1; if (kongzhi== ' d ') {month=month+1;if (month>12) {year=year+1;month=1;}} if (kongzhi== ' a ') {month=month-1;if (month<1){year=year-1; month=12;}} if (kongzhi== ' C ') break; System ("CLS"); Clear screen Clear screen printf ("\ n now:%d-%d-%d%d:%d:%d \ n \ nthe", P->tm_mon+1,p-> ; tm_mday,p->tm_year+1900,p->tm_hour,p->tm_min,p->tm_sec); Diao (year,month);} System ("CLS"); printf ("\n\n\n\n\n\n\n\n\t\t\t\t Thank you for using"); _sleep (10000);//delay function return 0;} void Diao (int year,int month) {int tian,space;//the number of days before this month tian= (year-1600) *365+leap (year); Tian=tian+jjmonth (Year,month) -1;space=tian%7;//Gets the number of spaces Shuchu (Space,year,month);} int Leap (int year) {int yan,i=0;//1600 to year number of leap years for (yan=1600;yan<year;yan+=4) {if (yan%4==0) && (yan%100! = 0) | | (yan%400 = = 0)) i++;} return i;} int jjmonth (int year,int month) {//year already past days if ((year%4==0) && (year%100! = 0) | | (year%400 = = 0)) {switch (month-1) {case 0:return 0;case 1:return 31;case 2:return 60;case 3:return 91;case 4:return 121;case 5:retu RN 152;case 6:return 182;casE 7:return 213;case 8:return 244;case 9:return 274;case 10:return 305;case 11:return 335; }}else {switch (month-1) {case 0:return 0;case 1:return 31;case 2:return 59;case 3:return 90;case 4:retur n 120;case 5:return 151;case 6:return 181;case 7:return 212;case 8:return 243;case 9:return 273;case 10:return 304;case 11 : Return 334; }}}void shuchu (int space,int year,int month) {int i; printf ("%d years%d months \n\n\n ", year,month); printf ("Sunday Monday Tuesday Wednesday Thursday Friday Saturday \ n"); printf ("-------------------------------------------------------\ n"); for (i=0;i<space;i++) printf ("");//First output space number for (I=1;i<month_of_day (year,month) +1;i++) {//This month how many days printf ("% 7d ", i); if ((space+i)%7==0) printf ("\ n");} printf ("\ n"); printf ("-------------------------------------------------------\ n"); printf ("Plus year W minus year s plus month D minus month a exit by c\n\n\n");} int Month_of_day (int year, int month) {//This month has how many days switch (month) {case 2:reTurn leap (year)? 29:28;//here to simplify the role case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31 ; Case 4:case 6:case 9:case 11:return 30; }}/*int get_leap (int year) {///Jobonnes is a leap year, February plus 1 if (year%4==0) && (year%100! = 0) | | (year%400 = = 0)) return 1; return 0;} */////////////////////////////---------------------------------/#include "stdio.h" #include "conio.h" #include " Time.h "#include" stdlib.h "void Diao (int year,int month);//The first called function, just gets space;int leap (int year);//is a leap year plus 1int Jjmonth ( int year,int month);//Calculate the total number of days for n months void Shuchu (int space,int year,int month);//output int get_leap (int year);//determine if leap year int month_ Of_day (int year, int month);//This month is a few days ah int main () {int year,month;int kongzhi; struct TM*P;//TM struct pointer time_t secs;//declaration time_t Type Variable time (&secs);//Get the system date P=localtime (&SECS);//Get local datetime time printf ("\ n Now: %d-%d-%d%d:%d:%d Week%d \ n ", P->tm_mon+1,p->tm_mday,p->tm_year+1900,p->tm_hour,p->tm_min,p->tm_sec,p->tm_wday); year=p->tm_year+1900;month=p->tm_mon+1; Diao (Year,month); while (1) {kongzhi=getch ();//Getch you don't have to press ENTER if (kongzhi== ' W ') year=year+1; if (kongzhi== ' s ') year=year-1; if (kongzhi== ' d ') {month=month+1;if (month>12) {year=year+1;month=1;}} if (kongzhi== ' a ') {month=month-1;if (month<1) {year=year-1; month=12;}} if (kongzhi== ' C ') break; System ("CLS"); Clear screen Clear screen printf ("\ n now:%d-%d-%d%d:%d:%d \ n \ nthe", P->tm_mon+1,p-> ; tm_mday,p->tm_year+1900,p->tm_hour,p->tm_min,p->tm_sec); Diao (year,month);} System ("CLS"); printf ("\n\n\n\n\n\n\n\n\t\t\t\t Thank you for using"); _sleep (10000);//delay function return 0;} void Diao (int year,int month) {int tian,space;//the number of days before this month tian= (year-1600) *365+leap (year); Tian=tian+jjmonth (Year,month) -1;space=tian%7;//Gets the number of spaces Shuchu (Space,year,month);} int Leap (int year) {int yan,i=0;//1600 to year number of leap years for (yan=1600;yan<year;yan+=4) {if (yan%4==0 && (yan%100! = 0) | | (yan%400 = = 0)) i++;} return i;} int jjmonth (int year,int month) {//year already past days int y=0; Plays a simplified role if ((year%4==0) && (year%100! = 0) | | (year%400 = = 0)) Y=1; Switch (month-1) {case 0:return 0;case 1:return 31;case 2:return 59+y;case 3:return 90+y;case 4:return 120+y;case 5:retu RN 151+y;case 6:return 181+y;case 7:return 212+y;case 8:return 243+y;case 9:return 273+y;case 10:return 304+y;case 11:retu RN 334+y; }}void shuchu (int space,int year,int month) {int i; printf ("%d years%d months \n\n\n ", year,month); printf ("Sunday Monday Tuesday Wednesday Thursday Friday Saturday \ n"); printf ("-------------------------------------------------------\ n"); for (i=0;i<space;i++) printf ("");//First output space number for (I=1;i<month_of_day (year,month) +1;i++) {//This month how many days printf ("% 7d ", i); if ((space+i)%7==0) printf ("\ n");} printf ("\ n"); printf ("-------------------------------------------------------\ n "); printf ("Plus year W minus year s plus month D minus month a exit by c\n\n\n");} int Month_of_day (int year, int month) {//How many days this month is switch (month) {Case 2:return get_leap (year)? 29:28; Case 1:case 3:case 5:case 7:case 8:case 10:case 12:return 31; Case 4:case 6:case 9:case 11:return 30; }} int Get_leap (int year) {//Jobonnes is a leap year, February plus 1 if ((year%4==0) && (year%100! = 0) | | (year%400 = = 0)) return 1; return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Calendar Calendar Calendars