设计MyTime类 代码参考
- #include <iostream>
- #include <cstdio>
- using namespace std;
- class MyTime
- {
- private:
- int hour;
- int minute;
- int second;
- public:
- void SetTime(){cin>>hour>>minute>>second;return;}
- void print_12();
- void print_24();
- };
- void MyTime::print_12()
- {
- if(hour<)
- {
- printf("%02d:%02d:%02d AM\n",hour,minute,second);
- }
- else
- {
- printf("%02d:%02d:%02d PM\n",hour-,minute,second);
- }
- return;
- }
- void MyTime::print_24()
- {
- printf("%02d:%02d:%02d\n",hour,minute,second);
- return;
- }
- int main()
- {
- MyTime one;
- one.SetTime();
- one.print_12();
- one.print_24();
- return ;
- }
设计MyTime类 代码参考的更多相关文章
- 设计一个多功能的MyTime类 代码参考
#include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...
- 设计Dog类 代码参考
#include <iostream> #include <string> using namespace std; class Dog { private: string n ...
- 设计Person类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 设计Weekday类 代码参考
#include <iostream> using namespace std; class Weekday { private: int num; public: void SetDay ...
- 设计带构造函数的Dog类 代码参考
#include <iostream> #include <string> using namespace std; class Dog { private: string n ...
- 设计并测试Trapezium类 代码参考
#include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...
- 从Student类和Teacher类多重派生Graduate类 代码参考
#include <iostream> #include <cstring> using namespace std; class Person { private: char ...
- 从Point类继承的Circle类 代码参考
#include <iostream> #include <cstring> using namespace std; class Point { private: int x ...
- 一个基类Person的多个派生类 代码参考
#include <iostream> #include <cstring> using namespace std; class Person { protected: ch ...
随机推荐
- Hello World的五十种不同实现方法!!!!!
我们作为一名程序员,职业生涯中至少完成了一个“Hello, World!“程序.当我们学习一门新的语言时,“Hello, World!“通常是我们所写的第一个程序.程序员一般也都会使用多门语言,甚至有 ...
- Spring AOP概述
一.AOP的基本概念: 首先先给出一段比较专业的术语: 在软件业,AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功能的 ...
- libevent(八)激活事件
激活事件添加流程 事件发生后,需要把对应的event加入到激活事件队列中. 整个流程如下: 对于定时器事件,在timeout_process过程中,会将事件从最小堆中删除. 激活事件处理流程 在eve ...
- ArcMap 0 (ArcGIS10.2安装)
一如GIS深似海,从此相逢是故人(这句话适合初步接触GIS的,我算是初窥门径.还是道行太浅,只是多了感慨) 前言: 1. 本人GIS专业,对于ArcGIS较为熟悉.由于专业和其它经历需要,接触过不少各 ...
- php接口开发经验总结
接口开发采用jwt方式验证: 接口开发最好留多几个返回方式,方便本地调用: 待更新.............
- Scrapy+selenium爬取简书全站
Scrapy+selenium爬取简书全站 环境 Ubuntu 18.04 Python 3.8 Scrapy 2.1 爬取内容 文字标题 作者 作者头像 发布日期 内容 文章连接 文章ID 思路 分 ...
- for do-while while区别
分别用for do-while while求1-100的和
- 数据结构学习:二叉查找树的概念和C语言实现
什么是二叉查找树? 二叉查找树又叫二叉排序树,缩写为BST,全称Binary Sort Tree或者Binary Search Tree. 以下定义来自百度百科: 二叉排序树或者是一棵空树,或者是具有 ...
- CF-612D The Union of k-Segments 差分
D. The Union of k-Segments 题意 给出n个线段,以及一个数字k,让求出有哪些线段:线段上所有的点至少被覆盖了k次. 思路 假如忽略掉线段的左右端点范围,肯定是使用差分来维护每 ...
- [POJ1038]状压DP
题意:给一个n*m的区域,里面有一些障碍物,往里面放2*3和3*2的矩形,矩形之间不能重叠,不能覆盖到障碍物,求能放置的最大个数.(n<=150,m<=10) 思路:看到m=10就应该往状 ...