【洛谷】P5716 【深基3.例9】月份天数

阅读 38

2022-01-20

原题链接

P5716 【深基3.例9】月份天数

ac代码

#include <iostream> 
using namespace std;												
int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; //打表 
int main() {
	int year, month;
	cin >> year >> month; 
	
	if ((year % 4 == 0 && year % 100 != 0) || n % 400 == 0)
		a[2] = 29;//先变
		
	cout << a[month];//直接输出 
	return 0;		  
}

相关推荐

精彩评论(0)

0 0 举报