# 生日日数

2017-12-18 18:36:15来源:CSDN作者:Soul_97人点击

## 1263: 生日日数

#### 题目描述：

CCC老师的生日是YY年MM月DD日，他想知道自己出生后第一万天纪念日的日期（出生日算第0天）。

#### 输出：

`1979 4 16`

`2006-9-1`
`东秦oj真是有毒  通过率100%然后下面给我来个编译错误`
`先贴下我自己的吧，思路还是差不多，感觉就是写的有点麻烦了，代码有点多，一直有一个检测点没过。。。`
`#include<bits/stdc++.h>using namespace std;int judgeyear(int n){	if((n % 4 == 0 && n % 100 != 0) || n % 400 == 0)	return 366;	else	return 365;}int judgeday(int m,int y){	switch(m)	{		case 1:		case 3:		case 5:		case 7:		case 8:		case 10:		case 12:return 31;break;		case 2:			if(y == 365)			{				return 28;				break;			}			else			{				return 29;				break;			}		case 4:		case 6:		case 9:		case 11:return 30;break;			}}int main(){	int year,month,day;	int sum;	while(~scanf("%d%d%d",&year,&month,&day))	{		sum = 10000;		while(1)		{			if(sum - judgeyear(year + 1) > 0)			{				year += 1;				sum -= judgeyear(year);			}			else			break;		}		//跳出循环后总天数不到365		sum = sum - (judgeday(month,year) - day);//先减去不是整月的		month ++;		while(1)		{			if(sum - judgeday(month,year) > 0)			{				sum -= judgeday(month,year);				month ++;			}			else			break;		}		day = sum;		cout<<year<<"-"<<month<<"-"<<day<<endl;	}	return 0;}`
`直接暴力枚举  简单多了`
`#include<bits/stdc++.h>using namespace std;int main(){	int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};	int y,m,d;	while(~scanf("%d%d%d",&y,&m,&d))	{		for(int i = 1;i <= 10000;i ++)		{			d ++;			if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)			day[2] = 29;			else			day[2] = 28;				if(d > day[m])			{				d = 1;				m ++;			}			if(m > 12)			{				m = 1;				y ++;			}		}		cout<<y<<"-"<<m<<"-"<<d<<endl;	}			return 0;}`