代码
本次项目的难点在于:输入的年月的第一天是星期几? 本文是以2000年1月作模板对比,计算输入年月与2000年1月所差天数n,
通过对7的除余运算:n % 7
算出输入年月的第一天是星期几
#include <iostream>
#include<iomanip>
#include<windows.h>
#include<string>
#include<vector>
#include<array>
using namespace std;
bool judge_runnian(int year) {
/*judge_runnian:判断是否是闰年*/
bool ifrun;
if ((year % 4 == 0) & (year % 100 != 0)) {
ifrun = true;
}
else if ((year % 4 == 0) & (year % 400 == 0)) {
ifrun = true;
}
else {
ifrun = false;
}
return ifrun;
}
vector