当前位置:网站首页>CCF date calculation (Full Score code + skill summary) February 2, 2015
CCF date calculation (Full Score code + skill summary) February 2, 2015
2022-06-30 14:41:00 【A cute little monkey】
Skill summary
Topic of date calculation , Remember this template
int months[13] = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool Is_Leap(int y)
{
if (y % 4 == 0 && y % 100 || y % 400 == 0) return 1;
else return 0;
}
int get_days(int y, int m)
{
int d = months[m];
if (m == 2) d += Is_Leap(y);
return d;
}
Title Description

Code implementation
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int months[13] = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool Is_Leap(int y)
{
if (y % 4 == 0 && y % 100 || y % 400 == 0) return 1;
else return 0;
}
int get_days(int y, int m)
{
int d = months[m];
if (m == 2) d += Is_Leap(y);
return d;
}
int main()
{
int y, d;
cin >> y >> d;
for (int i = 1; i < 13; i ++)
{
for (int j = 1; j <= get_days(y, i); j ++)
{
if (-- d == 0)
{
cout << i << endl << j;
return 0;
}
}
}
return 0;
}
边栏推荐
- Double pointer palindrome string
- Shangpinhui knowledge points of large e-commerce projects
- V3 01_ Welcome
- Upgrade composer self update
- 数据恢复软件EasyRecovery15下载
- Cost forecast of PMP (BAC, EAC, etc)
- @Component use cases
- Laravel8 custom log directory, rename
- Binary rotation array (2)
- LIS error: this configuration section cannot be used in this path
猜你喜欢

Go language mutex lock

Race of golang

ThinkPHP v3.2 comment annotation injection write shell

XSS challenge (6-10) more detailed answers

go channel && select

Summary of use of laravel DCAT admin

Component communication mode

Laravel configures passport and returns token using JWT

After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs

Notes on reverse learning in the first week of winter vacation
随机推荐
K high frequency elements before sorting
Sum of squares of two pointers
DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
[extensive reading of papers] multimodal joint attribute prediction and value extraction for e-commerce product
Project management - common English vocabulary I
@Role of ResponseBody
Wechat applet realizes map navigation + door-to-door recycling
Att & CK red team evaluation field (I)
Lfi-rce without controllable documents
DefCamp Capture the Flag (D-CTF) 2021-22 web
Location of dichotomy
Computer screenshot how to cut the mouse in
Laravel upload error
Programming exercises: whole point and circle (solution ideas and code implementation)
Greedy interval problem (5)
[extensive reading of papers] multimodal attribute extraction
Laravel artist command error
中信期货开户麻烦吗安全吗,期货开户手续费是多少,能优惠吗
KnightCTF WEB
Problems in QT creator (additional unknown and error lines are listed in the debug output window)