计算日期公式(根据年月日算星期几)

  • Post author:
  • Post category:其他


# include <iostream>
# include <string.h>
using namespace std;

int CaculateWeekDay(int y, int m, int d)
{
	int week = -1;
	if(m == 1 || m == 2)
	{
	m += 12;
	y--;
	}
		

	week = (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7;

	return week;
}

int main()
{
	cout<<CaculateWeekDay(2013, 8, 4)<<endl;
	return 0;
}



版权声明:本文为qq_33204081原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。