YTU 2614: A代码完善--系统日期
2614: A代码完善--系统日期
时间限制: 1 Sec 内存限制: 128 MB
提交: 216 解决: 113
题目描述
注:本题只需要提交填写部分的代码,请按照C++方式提交。
已知某操作系统的默认日期时间格式为 MMDDhhmmYYYY.ss ,其中YYYY表示年,MM表示月,DD表示日,hh表示小时,mm表示分种,ss表示秒。
按要求设计日期时间类DateTime,显示指定格式的日期。
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
class Date
{
public:
Date(int year,int month,int day):year(year),month(month),day(day) {}
Date(const Date &d)
{
this->year=d.year;
this->month=d.month;
this->day=d.day;
}
protected:
int year;
int month;
int day;
};
class Time
{
public:
Time(int hour,int minute,int seconds):hour(hour),minute(minute),seconds(seconds) {}
Time(const Time &t)
{
this->hour=t.hour;
this->minute=t.minute;
this->seconds=t.seconds;
}
protected:
int hour;
int minute;
int seconds;
};
/*************************
在此处补充和修改你的代码
class DateTime :protected Date,protected Time
{
public:
DateTime(Date &d, Time &t )
void show()
};
**************************/
int main()
{
int year,month,day;
cin>>year>>month>>day;
Date d1(year,month,day);
int hour,minute,seconds;
cin>>hour>>minute>>seconds;
Time t1(hour,minute,seconds);
DateTime dt(d1,t1);
dt.show();
return 0;
}
输入
年 月 日 小时 分钟 秒
输出
按格式MMDDhhmmYYYY.ss显示日期
样例输入
2014 7 10 10 30 15
样例输出
071010302014.15
提示
前导0的输出,printf("%02d",5) ; 显示为 05。
迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……
#include <iostream>
#include <stdio.h>
#include <iomanip>
using namespace std;
class Date
{
public:
Date(int year,int month,int day):year(year),month(month),day(day) {}
Date(const Date &d)
{
this->year=d.year;
this->month=d.month;
this->day=d.day;
}
protected:
int year;
int month;
int day;
};
class Time
{
public:
Time(int hour,int minute,int seconds):hour(hour),minute(minute),seconds(seconds) {}
Time(const Time &t)
{
this->hour=t.hour;
this->minute=t.minute;
this->seconds=t.seconds;
}
protected:
int hour;
int minute;
int seconds;
};
class DateTime :protected Date,protected Time
{
public:
DateTime(Date &d, Time &t ): Date(d),Time (t) {}
void show()
{
printf("%02d%02d%02d%02d%d.%02d\n",month,day,hour,minute,year,seconds);
}
};
int main()
{
int year,month,day;
cin>>year>>month>>day;
Date d1(year,month,day);
int hour,minute,seconds;
cin>>hour>>minute>>seconds;
Time t1(hour,minute,seconds);
DateTime dt(d1,t1);
dt.show();
return 0;
}
#include <stdio.h>
#include <iomanip>
using namespace std;
class Date
{
public:
Date(int year,int month,int day):year(year),month(month),day(day) {}
Date(const Date &d)
{
this->year=d.year;
this->month=d.month;
this->day=d.day;
}
protected:
int year;
int month;
int day;
};
class Time
{
public:
Time(int hour,int minute,int seconds):hour(hour),minute(minute),seconds(seconds) {}
Time(const Time &t)
{
this->hour=t.hour;
this->minute=t.minute;
this->seconds=t.seconds;
}
protected:
int hour;
int minute;
int seconds;
};
class DateTime :protected Date,protected Time
{
public:
DateTime(Date &d, Time &t ): Date(d),Time (t) {}
void show()
{
printf("%02d%02d%02d%02d%d.%02d\n",month,day,hour,minute,year,seconds);
}
};
int main()
{
int year,month,day;
cin>>year>>month>>day;
Date d1(year,month,day);
int hour,minute,seconds;
cin>>hour>>minute>>seconds;
Time t1(hour,minute,seconds);
DateTime dt(d1,t1);
dt.show();
return 0;
}
YTU 2614: A代码完善--系统日期的更多相关文章
- YTU 2616: A代码完善--简易二元运算
2616: A代码完善--简易二元运算 时间限制: 1 Sec 内存限制: 128 MB 提交: 280 解决: 187 题目描述 注:本题只需要提交填写部分的代码,请按照C++方式提交. 编写二 ...
- YTU 2611: A代码完善--向量的运算
2611: A代码完善--向量的运算 时间限制: 1 Sec 内存限制: 128 MB 提交: 256 解决: 168 题目描述 注:本题只需要提交填写部分的代码,请按照C++方式提交. 对于二维 ...
- 【运维工具】Git代码发布系统
引言 代码发布系统是互联网公司必备的运维系统,作用主要用户发布业务代码 到 业务服务器 为什么需要代码发布系统 有的同学可能说,我们公司服务器就那么一台,做个发布系统太麻烦了? 不认同这说法 发布系统 ...
- android 中 系统日期时间的获取
import java.text.SimpleDateFormat; SimpleDateFormat formatter = new SimpleDateFormat ...
- 我使用过的Linux命令之date - 显示、修改系统日期时间
原文地址:http://www.cnblogs.com/diyunpeng/archive/2011/11/20/2256538.html 用途说明 ate命令可以用来显示和修改系统日期时间,注意不是 ...
- 1.6 flask应用: 代码统计系统
2019-1-6 15:57:18 今天的是做了一个代码统计的demo 使用了数据库的连接池 参考连接 https://www.cnblogs.com/wupeiqi/articles/8184686 ...
- 我使用过的Linux命令之date - 显示、修改系统日期时间(转)
用途说明 ate命令可以用来显示和修改系统日期时间,注意不是time命令. 常用参数 格式:date 显示当前日期时间. 格式:date mmddHHMM 格式:date mmddHHMMYYYY 格 ...
- 不修改系统日期和时间格式,解决Delphi报错提示 '****-**-**'is not a valid date and time
假如操作系统的日期格式不是yyyy-MM-dd格式,而是用strtodate('2014-10-01')) 来转换的话,程序会提示爆粗 '****-**-**'is not a valid date ...
- Linux date命令 - 显示和设置系统日期与时间
操作系统上的时间也许只是当做一个时钟.特别在控制台下, 我们通常并不认为时间有什么重要的.但是对于管理员,这种认识是错误的.你知道错误的日期和时间会导致你不能编译程序么? 因为日期和时间很重要,这或许 ...
随机推荐
- 【BZOJ】【3504】【CQOI2014】危桥
网络流/最大流 比较裸的最大流= = 无向图上走来回其实就等价与走两遍>_> 如果路径有相交其实不影响答案的 比较恶心的是两个人路过同一座桥,但走的方向不同互相抵消流量了…… 其实只要在第 ...
- 两种高性能I/O设计模式(Reactor/Proactor)的比较
原文出处: Alex Libman 译文出处:潘孙友 欢迎分享原创到伯乐头条 综述 这篇文章探讨并比较两种用于TCP服务器的高性能设计模式. 除了介绍现有的解决方案,还提出了一种更具伸缩性,只 ...
- 亚马逊 在线测试题目 amazon (变种的)三叉树的最近公共祖先问题
题目意思就是找一棵按上面链接所示的树对应的上面的两个点的最小公共祖先(LCP,Least Common Father),按照比较大小来依次返回自己的父亲节点就行了.具体看代码:getfather(a) ...
- Keil中的code关键字
一般说来,我们在C语言中定义的每一个变量初始化后都会占用一定的内存(RAM)空间.但是在keil中提供了一个特殊的关键字“code”,这个关键字在标准C中是没有的.其语法举例如下: unsigned ...
- js函数延迟执行
function delay(value){ //全局变量保存当前值 window._myTempDalayValue = value; setTimeout(function(){ //延时之后与全 ...
- 偏序集的Dilworth定理
定理1 令(X,≤)是一个有限偏序集,并令r是其最大链的大小.则X可以被划分成r个但不能再少的反链.其对偶定理称为Dilworth定理:定理2 令(X,≤)是一个有限偏序集,并令m是反链的最大的大小. ...
- jQuery1.9.1--结构及$方法的工作原理源码分析
jQuery的$方法使用起来非常的多样式,接口实在太灵活了,有点违反设计模式的原则职责单一.但是用户却非常喜欢这种方式,因为不用记那么多名称,我只要记住一个$就可以实现许多功能,这个$简直就像个万能的 ...
- POJ 1459
#include<iostream> #define MAXN 105 #include"queue" #define big_num 100000000 using ...
- Xamarin for Mac 2.0.2.35 稳定版 破解补丁 Preview 2
注意:该破解补丁未经过广泛测试 前提概要 1.该补丁,仅涉及以下产品,所有版权归 Xamarin 所有,仅供学习练手: ① Xamarin.iOS 8.10.2.37 Xamarin.iOS 8.10 ...
- 在Jmeter中使用自定义编写的Java测试代码
我们在做性能测试时,有时需要自己编写测试脚本,很多测试工具都支持自定义编写测试脚本,比如LoadRunner就有很多自定义脚本的协议,比如"C Vuser","Java ...