文章

16

粉丝

0

获赞

1

访问

3.5k

头像
这是第几天? 题解:
P1542 云南大学/暨南大学机试题
发布于2026年1月29日 14:59
阅读数 8

#include<iostream>
#include<cstdio>

using namespace std;

int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool is_year(int year) {
	return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
}

int main() {
	int year, month, day;
	scanf("%d-%d-%d",&year,&month,&day);
	if (is_year(year)) months[2] = 29;
	int ans = 0;
	for (int i = 1; i < month; i ++)
		ans += months[i];
	ans += day;
	cout << ans << endl;
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发