算法设计与编程 每月天数

62 阅读1分钟

赛氪OJ-专注于算法竞赛的在线评测系统 (saikr.com)

#include <bits/stdc++.h>
using namespace std;
int y, m;

const int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int is_leap(int y) {
	if ((y % 4 == 0 || y % 100) && y % 400 == 0)
		return 1;
	return 0;
}
int main() {
	cin >> y >> m;

	cout << months[m] + is_leap(y);

	return 0;
}