当前位置:网站首页>日期类(暑假每日一题 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;
}
边栏推荐
- J9数字论:Web3.0+互联网电商会引起怎样的火花?
- placeholder 1
- 深度剖析“八大排序”(上)_ 探寻一些不为人知的细节
- winget包管理器
- Solve the problem that the win10win7win8 system cannot find the specified module and cannot register the desert plug-in
- js函数聚合的三种实现方式
- day16--抓包工具Charles的使用
- 不想再干会计了,蝶变向新,勇往直前,最后成功通过转行测试实现月薪翻倍~
- 速卖通卖家如何抓住产品搜索权重
- mySQL add, delete, modify and check advanced
猜你喜欢

Docker搭建Mysql一主一从

Rust learning: 6.1_Slices of composite types

Solve the problem that the win10win7win8 system cannot find the specified module and cannot register the desert plug-in

DAY26: GetShell project
![[OAuth2] 20. OAuth2 Extended Protocol PKCE](/img/ff/37f3be22bf209222cadaf5d11f951a.png)
[OAuth2] 20. OAuth2 Extended Protocol PKCE

iwemeta metaverse: a doll sells for 9999 yuan, and Bubble Mart thinks it is not expensive at all

速卖通卖家如何抓住产品搜索权重

ARM体系结构2:处理器内核和汇编指令集

协同工具满足70%-90%的工作需求,成为企业香饽饽

The implementation of the seemingly useless component (text gradient) in NaiveUI is so simple
随机推荐
物联网时代下的网络整合推广外包精准化效果-深圳双赢世讯
Go-Excelize API源码阅读(十一)—— GetActiveSheetIndex()
SQL SERVER 数据库,表的数据发生增删改,该表的索引会在ldf日志中记录吗?
uni 小程序腾讯地图polygon背景透明度
[机缘参悟-65]:《兵者,诡道也》-7-三十六计解读-败战计
协同工具满足70%-90%的工作需求,成为企业香饽饽
【Unity入门计划】Collision2D类&Collider2D类
Rust learning: 6.5_Array of composite types
TensorFlow 2.9的零零碎碎(一)
Rust learning: 6.2_ Tuples of composite types
UGUI - Events, iTween Plugin
颜色选择器的使用
【 WeChat applet 】 read page navigation
Day36 LeetCode
winget包管理器
day16--The use of the packet capture tool Charles
并查集模板
封装和使用通用的工具栏组件
硬件工程师90天学习资料及笔记汇总
qrcode-----生成二维码