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命令 - 显示和设置系统日期与时间
操作系统上的时间也许只是当做一个时钟.特别在控制台下, 我们通常并不认为时间有什么重要的.但是对于管理员,这种认识是错误的.你知道错误的日期和时间会导致你不能编译程序么? 因为日期和时间很重要,这或许 ...
随机推荐
- css中的border还可以这样玩
在看这篇文章之前你可能会觉得border只是简单的绘制边框,看了这篇文章,我相信你也会跟我一样说一句"我靠,原来css中的border还可以这样玩".这篇文章主要是很早以前看了别人 ...
- 【CTSC 2015】&【APIO 2015】酱油记
蒟蒻有幸参加了神犇云集的CTSC & APIO 2015,感觉真是被虐成傻逼了……这几天一直没更新博客,今天就来补一下吧~~(不过不是题解……) Day 0 从太原到北京现在坐高铁只需3小时= ...
- 【BZOJ】【1018】【SHOI2008】堵塞的交通traffic
线段树 这题的线段树+分类讨论蛮神奇的……我以前学的线段树简直就是渣渣QAQ 看了下ydc题解里的思想>_>用线段树维护连通性!那么就自己写吧……每个节点表示一段区间的连通性(我的叶子节点 ...
- JAVA 关于Icon,Image,ImageIcon的简单的对比参考 分类: Java Game 2014-08-14 17:08 210人阅读 评论(0) 收藏
转自:http://blog.csdn.net/bcmissrain/article/details/7190886 其实就算是现在,我还是有不少地方概念模糊,但是下面的内容是是没有什么问题的.稍微介 ...
- POJ 2724
Purifying Machine Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4014 Accepted: 1127 ...
- 免安装jdk 和 免安装tomcat
免安装tomcat 运行的时候要执行免安装的 jdk,可以进行如下设置. 在 startup.bat 里加上这么一句, set "JAVA_HOME=C:\jdk1.6.0_43"
- [你必须知道的.NET]第二十九回:.NET十年(上)
发布日期:2009.05.08 作者:Anytao © 2009 Anytao.com ,Anytao原创作品,转贴请注明作者和出处. /// <summary> /// 本文部分内容,已 ...
- MongoDB (九) MongoDB 投影
mongodb 投影意思是只选择必要的数据而不是选择一个文件的数据的整个.如果一个文档有5个字段,需要显示只有3个,然后选择其中只有3个字段. find() 方法 MongoDB 的find()方法, ...
- Spark源码编译
原创文章,转载请注明: 转载自http://www.cnblogs.com/tovin/p/3822995.html spark源码编译步骤如下: cd /home/hdpusr/workspace ...
- java 语法错误 (操作符丢失) 在查询表达式
遇到的详细问题: a[0]="11"; a[1]="2223"; a[2]="333"; sta.executeUpdate("i ...