Galaxy bomb
There are many X-star artificial "bombs" floating in the vast space of the X galaxy, which are used as road signs in the universe.
Each bomb can be set to explode in days.
For example, if the Alpha Bomb is placed on January 1, 2015 and the time is 15 days, it will explode on January 16, 2015.
There is a beta bomb, which was placed on November 9, 2014, with a timing of 1000 days. Please calculate the exact date when it exploded.
Please fill in the date, the format is yyyy-mm-dd which is a 4-digit year, 2-digit month and 2-digit date. For example: 2015-02-19
please write in strict accordance with the format. No other words or symbols can appear
Answer:
2017-08-05
Reprinted: FISHers
Tool implementation
Code implementation:
reprinted: vx public number (ICT communication people's home)
#include<stdio.h>
#define Days 1000
int main(){
int monthday[12]={
31,28,31,30,31,30,31,31,30,31,30,31};
int year=2014,month=11,day=9,i;
//判断该年是闰年还是平年
if(year%400==0 || (year%4==0 && year%100!=0))
monthday[1]=29;
else
monthday[1]=28;
for(i=0;i<Days;i++)
{
day++;
if(day>monthday[month-1])
{
day=1;
month++;
if(month>12)
{
month=1;
year++;
if(year%400==0 || (year%4==0 && year%100!=0))
monthday[1]=29;
else
monthday[1]=28;
}
}
}
printf("%d-%02d-%02d",year,month,day);
return 0;
}