類和函式的宣告部分:
#includeusing namespace std;
class date
; bool judge_leap(int year);//判斷是否閏年
void print_date(int year,int month);//列印日期
int week_firstday(int year,int day);//計算要求月數的第一天是星期幾
函式實現:
ostream& operator<
date::date(int year = 2016,int month = 1,int day = 1)
:_year(year)
,_month(month)
,_day(day) }}
date::date(const date& d)
date& date::operator=(const date& d)
return *this;
} date date::operator+(int day)
}return *this;
} date& date::operator++()
}return *this;
} date date::operator++(int)
}return *this;
} date date::operator-(int day)
}return *this;
} int date::operator-(date& d)
else
int day = 0;
while(max > min)
return day;
} date& date::operator--()
_day = days_everymonth(_year,_month);
} return *this;
} date date::operator--(int)
_day = days_everymonth(_year,_month);
} return *this;
} bool date::operator>(const date& d)
}} bool date::operator
}} bool date::operator==(const date& d)
}} bool date::operator!=(const date& d)
bool date::operator>=(const date& d)
}} bool date::operator<=(const date& d)
} }
static bool judge_leap(int year)
static int week_firstday(int year,int month)
return week;
} date& date::display(const date &d)
{ cout<
void funtest()
{ date d1(2016,10,12);
cin>>d1;
d1++;
cout注意測試時列印某個月的日曆不要超過2023年9月,因為它是我們的日期原點,我們的**是以它為基準點朝後寫的。
還有不知你注意到這句話沒有system("color 1e"); 它是用來改變我們輸出時的字型和背景顏色的,來學習一下吧!
其中color後面的0是背景色代號,a是前景色代號。各顏色**如下:
0=黑色 1=藍色 2=綠色 3=湖藍色 4=紅色 5=紫色 6=黃色 7=白色 8=灰色 9=淡藍色
a=淡綠色 b=淡淺綠色 c=淡紅色 d=淡紫色 e=淡黃色 f=亮白色
讀者可根據自己的喜好設定背景顏色
C 列印日曆
1 include 2 include 3using namespace std 45 int isleap int y,int m,int d 四年一潤,百年不潤,四百在潤。611 12int all day int m,int d 13 邊定義邊賦值。15int sum 0 16 sum sum...
C語言實驗 列印日曆
專案實現首先輸入公元後任意年份,然後可以列印出該年份的日曆。面向c語言初學者,大神輕噴hhh 下面是程式實際執行效果 先輸入年份 然後輸出日曆 想要輸出每年的日曆,首先要確立乙個基準年。本人以公元1年為基準年,公元1年第一天定為星期日。以公元第一年遞推,從而推出每年的第一天是星期幾。也可以用計算公式...
SQL列印全年日曆
資料庫環境 sql server 2008r2 我之前有寫過列印本月日曆的sql,裡頭有詳細的說明。具體請參考前面的博文 生成本月日曆。全年日曆只是在本月日曆的基礎上加了月資訊,並按月份分組求得。下面直接分享sql 基礎資料 年初日期,全年有多少天 with x0 as select convert...