当前位置:网站首页>*7-2 CCF 2015-09-2 date calculation
*7-2 CCF 2015-09-2 date calculation
2022-07-25 09:39:00 【Ye Xiaobai】
Date calculation
Title Description

Source code
#include<iostream>
using namespace std;
int days[13] = {
0,31,28,31,30,31,30,31,31,30,31,30,31 };
int isleapyear(int year)
{
return ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) ? 1 : 0;
}
int main()
{
int y, d;
cin >> y >> d;
int leap = isleapyear(y);
int month = 1;
while (d>days[month])
{
d -= days[month];
if (month == 2 && leap)
d -= 1;
month++;
}
cout << month << endl;
cout << d << endl;
return 0;
}
边栏推荐
猜你喜欢
随机推荐
How to obtain location information (longitude and latitude) by uni app
【代码源】每日一题 添加括号
【代码源】每日一题 分数拆分
Basic network knowledge
*6-1 CCF 2015-03-2 数字排序
正奇边形可划分成多少区域
Machine learning -- detailed introduction of standardscaler (), transform (), fit () in sklearn package
对象数据如何转化成数组
用kotlin怎么写Android切换界面
Learn redis Linux and install redis
OC--初识
学习 Redis linux 安装Redis
OC -- category extension agreement and delegation
kotlin基础知识点
[De1CTF 2019]SSRF Me
How to write Android switching interface with kotlin
Flex 布局语法与用例
Use of map () function in JS
【代码源】 每日一题 素数之欢(bfs)
单例模式(Singleton)








