当前位置:网站首页>日期类(暑假每日一题 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;
}
边栏推荐
- 解决win10win7win8系统找不到指定的模块,注册不了大漠插件的问题
- CTFSHOW七夕杯web
- [机缘参悟-65]:《兵者,诡道也》-7-三十六计解读-败战计
- 同步锁synchronized追本溯源
- Linux下载安装MySql
- 问下cdc mysql to doris.不显示具体行数,怎么办?
- Class Notes (7) (1) - #647. Find the root and the child (root)
- 封装和使用通用的工具栏组件
- 不想再干会计了,蝶变向新,勇往直前,最后成功通过转行测试实现月薪翻倍~
- [OAuth2] Nineteen, OpenID Connect dynamic client registration
猜你喜欢
Rust learning: 6.3_ Tuples of composite types
J9数字论:Web3.0+互联网电商会引起怎样的火花?
PTA 习题2.2 数组循环左移
MySQL的用户临时表与内部临时表
深度剖析“八大排序”(上)_ 探寻一些不为人知的细节
Delphi实现的一个文件在线查询显示下载功能
IDLE development wordCount program (5)
协同工具满足70%-90%的工作需求,成为企业香饽饽
How AliExpress sellers seize product search weight
Synchronization lock synchronized traces the source
随机推荐
Delphi实现的一个文件在线查询显示下载功能
详解构建mock服务最方便的神器——Moco
LaTeX出现错误代码Command \algorithmic already defined
SQL SERVER 数据库,表的数据发生增删改,该表的索引会在ldf日志中记录吗?
Rust learning: 6.1_Slices of composite types
Rust learning: 6.3_ Tuples of composite types
大佬们,请问一下,oraclecdc报错没有序列化,可是我看源码中的确是没有继承序列化的,是什么原因
qrcode-----生成二维码
【NeRF】原始论文解读
[Learn Rust together | Advanced articles | RMQTT library] RMQTT message server - installation and cluster configuration
CV-人脸识别-2018:ArcFace
编程老手如何在autojs和冰狐智能辅助之间选择?
Relaxation class: the boss will martial arts, who also can not hold up against!The charm of six sigma training
J9 Number Theory: Macro Analysis of DAO Characteristics
1499. 满足不等式的最大值 堆/双端队列
js reduce
【OAuth2】十九、OpenID Connect 动态客户端注册
Is the write performance of raid5 faster than raid10?
不同的命令行风格
The precise effect of network integration promotion outsourcing in the era of Internet of Things-Shenzhen Win-Win World News