# 星系炸弹（蓝桥杯）

#### 题目

#include <stdio.h>

int main()
{
int monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int days = 1000;
int year = 2014, month = 11, day = 9;
int i;

for (i = 0; i < days; i++)
{
day++;
if (day > monthDays[month - 1])
{
day = 1;
month++;
if (month > 12)
{
month = 1;
year++;
____________________;
}
}
}

printf("%d-%d-%d\n", year, month, day);

getchar();
return 0;
}

#### 代码

#include <stdio.h>

int main()
{
int monthDays[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int days = 1000;
int year = 2014, month = 11, day = 9;
int i;

for (i = 0; i < days; i++)
{
day++;
if (day > monthDays[month - 1])
{
day = 1;
month++;
if (month > 12)
{
month = 1;
year++;
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
months[2] = 29;
else
months[2] = 28;
}
}
}

printf("%d-%d-%d\n", year, month, day);

getchar();
return 0;
}

|
11天前

7 0
|
10月前
1314：【例3.6】过河卒(Noip2002)
1314：【例3.6】过河卒(Noip2002)
99 0
【洛谷】独自一人听歌写题
【洛谷】独自一人听歌写题
55 0
|

【寒假每日一题】AcWing 4510. 寻宝！大冒险！

105 0
|

37 0

99 0

72 0
LeetCode每日一题——735. 行星碰撞

106 0
LeetCode每日一题——417. 太平洋大西洋水流问题

79 0
|

227 0