当前位置:网站首页>日期类(暑假每日一题 19)
日期类(暑假每日一题 19)
2022-08-10 08:34:00 【sweetheart7-7】
编写一个日期类,要求按 xxxx-xx-xx 的格式输出日期,实现加一天的操作。
输入格式
第一行包含整数 T T T,表示共有 T T T 组测试数据。
每组数据占一行,包含 3 3 3 个用空格隔开的整数,分别表示年月日。
输出格式
每组数据输出一行,一个结果,按 xxxx-xx-xx 的格式输出,表示输入日期的后一天的日期。
数据范围
输入日期保证合法且不会出现闰年。
年份范围 [ 1000 , 3000 ] [1000,3000] [1000,3000]
输入样例:
2
1999 10 20
2001 1 31
输出样例:
1999-10-21
2001-02-01
#include<iostream>
using namespace std;
int md[] = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void next_day(int& y, int &m, int &d){
d ++;
int days = md[m];
if((y % 400 == 0 || y % 100 != 0 && y % 4 == 0) && m == 2)
days++;
if(d > days) d %= days, m++;
if(m > 12) m %= 12, y++;
}
int main(){
int t;
cin >> t;
int y, m, d;
while(t--){
cin >> y >> m >> d;
next_day(y, m, d);
printf("%04d-%02d-%02d\n", y, m, d);
}
return 0;
}
边栏推荐
- [OAuth2] Nineteen, OpenID Connect dynamic client registration
- [机缘参悟-65]:《兵者,诡道也》-7-三十六计解读-败战计
- dayjs-----time format
- mySQL add, delete, modify and check advanced
- Binary tree --- heap
- Different command line styles
- 解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
- 2022-08-01 Advanced Network Engineering (24) STP Advanced Knowledge
- StringUtils的具体操作
- js-----数组转换成树形结构
猜你喜欢

day16--抓包工具Charles的使用

DAY26: GetShell project
![[OAuth2] Nineteen, OpenID Connect dynamic client registration](/img/01/2f318a06e130cc222aa1736abbd152.png)
[OAuth2] Nineteen, OpenID Connect dynamic client registration

iwemeta元宇宙:阿里首任COO:如何打造销售铁军

【搜索引擎】Solr:提高批量索引的性能

2022-08-01 网工进阶(二十四) STP进阶知识

ABAP Data Types 和XSD Type 映射关系以及XSD Type属性

Uni-app开发微信小程序使用本地图片做背景图

Quickly enter the current date and time
【一起学Rust | 进阶篇 | RMQTT库】RMQTT消息服务器——安装与集群配置
随机推荐
J9数字论:Web3.0+互联网电商会引起怎样的火花?
【Unity入门计划】2D游戏实现敌人来回移动控制脚本
【OAuth2】十九、OpenID Connect 动态客户端注册
基于sklearn的决策树应用实战
Guys, may I ask, the oraclecdc error report is not serialized, but I see that the source code does not inherit serialization, what is the reason?
二叉树 --- 堆
ARM Architecture 3: Addressing and Exception Handling of ARM Instructions
1499. The maximum pile.then/deque
高性能短连接设计
菜鸟、小白在autojs和冰狐智能辅助之间如何选择?
90. (cesium house) cesium height monitoring events
【Unity入门计划】制作RubyAdventure03-使用碰撞体&触发器实现世界交互
UGUI - Events, iTween Plugin
VS2013-debug assembly code-generate asm file-structure memory layout-function parameter stack-calling convention
NPU架构与算力分析
2022-08-01 网工进阶(二十三) VLAN高级技术-VLAN聚合、MUX VLAN
qrcode-----生成二维码
Uni-app develops WeChat applet using local images as background images
Rust学习:6.2_复合类型之元组
【Unity入门计划】Collision2D类&Collider2D类