今天到下次生日中间隔的天数C++

最近终于下定决心搞点小项目,练习自己的技术,做完了保存在这里,供大家交流。
以下程序完成一个日期到下次生日之间间隔的天数,可以直接运行。

#include
#include 
int Day[13] = {
    0,31,28,31,30,31,30,31,31,30,31,30,31 };
bool isLeap(int year)	//判断是否为闰年
{
   
	return (year % 4 == 0 || year % 400 == 0) && (year % 100 != 0);
}
int daysInMonth(int year, int month)	//返回某个月包含的天数
{
   
	if (isLeap(year))
	{
   
		Day[2] = 29;
	}
	return Day[month];
}
bool isLegal(int date[])	//判断日期是否合法
{
   
	int year = date[0];
	int month = date[1];
	int day = date[2];
	if (!isLeap(year))
	{
   
		return year > 0 && month > 0 && month <= 12 && day > 0 && day <= Day[month];
	}
	else
	{
   
		Day

你可能感兴趣的:(C++,VS2015,命令行,c++,开发语言,visualstudio,visual,studio)