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命令 - 显示和设置系统日期与时间
操作系统上的时间也许只是当做一个时钟.特别在控制台下, 我们通常并不认为时间有什么重要的.但是对于管理员,这种认识是错误的.你知道错误的日期和时间会导致你不能编译程序么? 因为日期和时间很重要,这或许 ...
随机推荐
- 我是IT小小鸟
我是IT小小鸟读后感 世界上没有一蹴而就的成功者,只有头悬梁锥刺股的奋斗者.蜉蝣向往大鹏的辉煌,却不曾知大鹏以往的汗水.蜉蝣之所以为蜉蝣,是因为它犹如井底之蛙,目光短浅,之盲目地羡慕成功者,而大鹏之所 ...
- 转 Eclipse下svn的创建分支/合并/切换使用
最近接项目要求,要在svn主干上创建分支,用分支来进行程序的bug修改,而主干上进行新功能的开发.分支上的bug修改完,发布后,可以合并到主干上.项目程序可以在主干和分支之间进行切换,来实现主干和分支 ...
- 百度Hi之CSRF蠕虫攻击
漏洞起因:百度是国内最大的中文搜索引擎.同时百度也提供了百度空间.百度贴吧等BLOG社区服务,拥有海量的用户群,号称全球最大中文社区. 80sec发现过百度产品一系列的安全漏洞,其中一些问题得到了有效 ...
- remoting技术
转: http://www.cnblogs.com/rickie/category/5082.html
- ios 5
1.屏幕尺寸568×2/320×2 需要一张568h@2x.png的图片. 2.iOS5不支持udid,用uuid替代,取得uuid方法: -(NSString*) uuid { CFUUIDRef ...
- 为现代JavaScript开发做好准备
今天无论是在浏览器中还是在浏览器外,JavaScript世界正在经历翻天覆地地变化.如果我们谈论脚本加载.客户端的MVC框架.压缩器.AMD.Common.js还有Coffeescript……只会让你 ...
- AssetBundle依赖关系
原地址:http://www.cnblogs.com/realtimepixels/p/3652086.html Unity AssetBundle Dependencies In the last ...
- 原 JS监听回车事件
原 JS监听回车事件 发表于2年前(2014-06-04 10:16) 阅读(6101) | 评论(0) 11人收藏此文章, 我要收藏 赞0 1月16日厦门 OSC 源创会火热报名中,奖品多多哦 ...
- HDU4512完美队形I && HDU1423 Greatest Common Increasing Subsequence (LCIS)
填坑的时候又到啦,校赛因为不会LCIS所以吃了大亏,这里要补起来.LCIS就是在两个串里找最长上升子序列,相关的博客有很多,这里自己就不写那么多了. http://www.cnblogs.com/ja ...
- C# 6 —— 属性
记录一下 C# 6 有关属性的语法糖实现,C# 6 涉及到属性的新特性主要有 2 个:自动属性初始化.只读属性赋值与读取. 自动属性初始化(Auto-property initializers) C# ...