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命令 - 显示和设置系统日期与时间
操作系统上的时间也许只是当做一个时钟.特别在控制台下, 我们通常并不认为时间有什么重要的.但是对于管理员,这种认识是错误的.你知道错误的日期和时间会导致你不能编译程序么? 因为日期和时间很重要,这或许 ...
随机推荐
- codeforces 161D Distance in Tree 树形dp
题目链接: http://codeforces.com/contest/161/problem/D D. Distance in Tree time limit per test 3 secondsm ...
- centos6.5安装图形界面,windows远程linux图形界面
1. 查询是否已安装图形界面 yum grouplist |more 在grouplist的输出结果中的“Installed Groups:”部分中,如果你能找到“X Window System”和G ...
- Detecting diabetic retinopathy in eye images
Detecting diabetic retinopathy in eye images The past almost four months I have been competing in a ...
- 常量折叠 const folding
http://bbs.byr.cn/#!article/CPP/86336?p=1 下列代码给出输出结果: #include"stdafx.h" #include <iost ...
- .NET设计模式(15):结构型模式专题总结(转)
摘要:结构型模式,顾名思义讨论的是类和对象的结构,它采用继承机制来组合接口或实现(类结构型模式),或者通过组合一些对象,从而实现新的功能(对象结构型模式).这些结构型模式,它们在某些方面具有很大的相似 ...
- AngularJs学习笔记--Forms
原版地址:http://code.angularjs.org/1.0.2/docs/guide/forms 控件(input.select.textarea)是用户输入数据的一种方式.Form(表单) ...
- AngularJs学习笔记--concepts(概念)
原版地址:http://code.angularjs.org/1.0.2/docs/guide/concepts 继续.. 一.总括 本文主要是angular组件(components)的概览,并说明 ...
- Android 4.4 KitKat, the browser and the Chrome WebView
Having V8 as the JavaScript engine for the new web view, the JavaScript performance if much better, ...
- 微信连WiFi关注公众号流程更新 解决ios微信扫描二维码不关注就能上网的问题
前几天鼓捣了一下微信连WiFi功能,设置还蛮简单的,但ytkah发现如果是ios版微信扫描微信连WiFi生成的二维码不用关注公众号就可以直接上网了,而安卓版需要关注公众号才能上网,这样就少了很多ios ...
- jQuery1.9.1--结构及$方法的工作原理源码分析
jQuery的$方法使用起来非常的多样式,接口实在太灵活了,有点违反设计模式的原则职责单一.但是用户却非常喜欢这种方式,因为不用记那么多名称,我只要记住一个$就可以实现许多功能,这个$简直就像个万能的 ...