当前位置:网站首页>3564. 日期类
3564. 日期类
2022-07-28 14:15:00 【追寻远方的人】
编写一个日期类,要求按 xxxx-xx-xx 的格式输出日期,实现加一天的操作。
输入格式
第一行包含整数 T,表示共有 T 组测试数据。
每组数据占一行,包含 3 个用空格隔开的整数,分别表示年月日。
输出格式
每组数据输出一行,一个结果,按 xxxx-xx-xx 的格式输出,表示输入日期的后一天的日期。
数据范围
输入日期保证合法且不会出现闰年。
年份范围 [1000,3000][1000,3000]
输入样例:
2
1999 10 20
2001 1 31
输出样例:
1999-10-21
2001-02-01
代码:
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int months[] = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
int n;
cin >> n;
while (n--)
{
int yy, mm, dd;
cin >> yy >> mm >> dd;
dd++;
if (dd > months[mm])
{
dd = 1;
mm++;
if (mm > 12)
{
mm = 1;
yy++;
}
}
printf("%04d-%02d-%02d\n", yy, mm, dd);
}
return 0;
}
边栏推荐
- Chapter I Introduction
- Idea2020.1.4 packages package collapse
- Solution: attributeerror: type object 'h5py.h5a AttrID has no attribute __ reduce_ cython__
- 8、 C scope rules
- 使用cpolar发布树莓派网页(apache2的安装测试)
- Creating, deleting and viewing Anaconda virtual environment
- 云计算需要考虑的安全技术列举
- 为什么企业需要用户自治的数字身 份
- Third class exercise
- @DS('slave') 多数据源兼容事务问题解决方案
猜你喜欢

VTK notes - picker picker summary

Foundation of knowledge atlas (II) - knowledge expression system of knowledge atlas

Google lab usage notes

Deploy flask on Alibaba cloud server
![UTF-8、UTF-16 和 UTF-32 字符编码之间的区别?[图文详解]](/img/a9/336390db64d871fa1655800c1e0efc.png)
UTF-8、UTF-16 和 UTF-32 字符编码之间的区别?[图文详解]

Wonderful frog -- how simple can it be to abandon the float and use the navigation bar set by the elastic box

The second 1024, come on!

Creating, deleting and viewing Anaconda virtual environment
![SQL error [1810] [22008]: ora-01810: format code occurs twice](/img/3b/4cbc0efe23f6f71163a115cd098ea9.png)
SQL error [1810] [22008]: ora-01810: format code occurs twice

MLX90640 红外热成像仪传感器模块开发笔记(八)
随机推荐
安装mosek,license安装位置查找
SSH service
How to gracefully encapsulate anonymous inner classes (DSL, high-order functions) in kotlin
Three pop-up boxes commonly used in JS
Google lab usage notes
Chapter I Introduction
Deploy flask on Alibaba cloud server
QT qbuttongroup realizes single selection and multiple selection
SQL error [1810] [22008]: ora-01810: format code occurs twice
Compilation failure caused by kotlin version upgrade
VTK annotation class widget vtkborderwidget
The modified network card name of rocky foundation is eth0
Introduction to MITK
23、 TF coordinate transformation (III): dynamic coordinate transformation
Enumeration type
19、 ROS parameter name setting
QT hex, decimal, qbytearray, qstring data conversion
Third class exercise
charles如何安装并使用
Using keras to visualize the network model, failed to import pydot appears