首页 > 试题广场 >

日期类

[编程题]日期类
  • 热度指数:11818 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
编写一个日期类,要求按xxxx-xx-xx 的格式输出日期,实现加一天的操作

输入描述:
输入第一行表示测试用例的个数m,接下来m行每行有3个用空格隔开的整数,分别表示年月日。测试数据不会有闰年。


输出描述:
输出m行。按xxxx-xx-xx的格式输出,表示输入日期的后一天的日期。
示例1

输入

2
1999 10 20
2001 1 31

输出

1999-10-21
2001-02-01

备注:
注意个位数日期前面要有0。
头像 渺小小螃蟹
发表于 2021-05-07 22:35:34
//终于碰到了熟悉的题,把日期累加题目中的number改成1就可以。#include<stdio.h>#include<stdbool.h> int daytab[2][13] ={ {0,31,28,31,30,31,30,31,31,30,31,30,31}, 展开全文
头像 BANG_
发表于 2022-03-11 13:43:25
知识点:基础数学、模拟 描述 编写一个日期类,要求按xxxx-xx-xx的格式输出日期,实现加一天的操作。 输入描述: 输入第一行表示测试用例的个数m,接下来m行每行有3个用空格隔开的整数,分别表示年月日。测试数据不会有闰年。 输出描述: 输出m行。按xxxx-xx-xx的格式输出,表示输入日期的后 展开全文
头像 乌龟狗的齐天大圣
发表于 2023-02-17 15:53:33
#include <stdio.h> int main(){ int n; int list1[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; scanf("%d",&n); for( 展开全文
头像 牛客182054830号
发表于 2023-03-26 09:23:46
#include <iostream> using namespace std; int m[13] = {0,31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; class Date { private: int year; 展开全文
头像 KimKitsuragi
发表于 2024-01-04 14:36:39
//日期类 北理 2024/1/4 //http://t.cn/E9RJUp4 #include <iostream> using namespace std; bool ifLeap(int year){ return (year%400==0)||(year%100!=0&a 展开全文
头像 在做毕设的鲸鱼很刻苦
发表于 2023-03-11 10:48:23
#include <cstdio> int main() { int n; int mdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; while (scanf("%d", &n) != 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-14 08:49:16
#include <bits/stdc++.h> using namespace std; int a1[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; int a2[] = {0,31,29,31,30,31,30,31,31,30,31,3 展开全文
头像 Perceive109
发表于 2023-01-12 19:35:46
#include "iostream" #include "iomanip" using namespace std; class date250 { // 日期类 private: int day; int year; int month; public: 展开全文
头像 yyer
发表于 2023-03-02 21:31:04
#include <iostream> using namespace std; int months[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}}; in 展开全文
头像 dreamta1e
发表于 2021-01-14 22:42:24
不考虑闰年的话,就考虑输入的是月末和年末两种边界情况了 #include <iostream> #include <cstdio> using namespace std; int monthtab[13]={0,31,28,31,30,31,30,31,31,30,31 展开全文

问题信息

上传者:小小
难度:
91条回答 5066浏览

热门推荐

通过挑战的用户

查看代码