第几天?

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

bool is_leap_year(int y)
{
	if((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
		return true;
	else
		return false;
}

int main()
{
	int month[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	int y, m, d, sum;
	
	while(~scanf("%d/%d/%d", &y, &m, &d))
	{
		sum = 0;
		month[2] = is_leap_year(y) ? 29 : 28;
		for(int i = 1; i < m; ++ i)
		{
			sum += month[i];
		}
		sum = sum + d;
		
		printf("%d\n", sum);
	}
	
	return 0;
}

  

posted @ 2019-07-23 16:15  青衫客36  阅读(127)  评论(0编辑  收藏  举报