#include <iostream>
#include <cstdio> using namespace std; class MyTime
{
private:
int hour;
int minute;
int second;
public:
MyTime(){hour=;minute=;second=;}
MyTime(int,int,int);
void Register(int,int,int);
void Show_12();
void Show_24();
void Sub(int,int,int);
void Add(int,int,int);
}; MyTime::MyTime(int a, int b, int c)
{
hour=a;
minute=b;
second=c;
} void MyTime::Show_12()
{
if(hour>)
{
printf("%02d:%02d:%02d PM\n",hour-,minute,second);
}
else
{
printf("%02d:%02d:%02d AM\n",hour,minute,second);
}
return;
} void MyTime::Show_24()
{
printf("%02d:%02d:%02d\n",hour,minute,second);
return;
} void MyTime::Sub(int a, int b, int c)
{
hour-=a;
minute-=b;
second-=c;
while(second<)
{
second+=;
minute-=;
}
while(minute<)
{
minute+=;
hour-=;
}
while(hour<)
{
hour+=;
}
return;
} void MyTime::Add(int a, int b, int c)
{
hour+=a;
minute+=b;
second+=c;
while(second>)
{
second-=;
minute+=;
}
while(minute>)
{
minute-=;
hour+=;
}
while(hour>)
{
hour-=;
}
return;
} void MyTime::Register(int a,int b, int c)
{
hour=a;
minute=b;
second=c;
return;
} int main()
{
MyTime one,two(,,);
int a,b,c,x,y,z;
cin>>a>>b>>c>>x>>y>>z;
one.Show_12();
one.Show_24();
two.Show_12();
two.Show_24();
one.Register(a,b,c);
one.Add(x,y,z);
two.Sub(x,y,z);
one.Show_12();
one.Show_24();
two.Show_12();
two.Show_24();
return ;
}

设计一个多功能的MyTime类 代码参考的更多相关文章

  1. 设计MyTime类 代码参考

    #include <iostream> #include <cstdio> using namespace std; class MyTime { private: int h ...

  2. 设计一个 Java 程序,自定义异常类,从命令行(键盘)输入一个字符串,如果该字符串值为“XYZ”。。。

    设计一个 Java 程序,自定义异常类,从命令行(键盘)输入一个字符串,如果该字符串值为“XYZ”,则抛出一个异常信息“This is a XYZ”,如果从命令行输入 ABC,则没有抛出异常.(只有 ...

  3. 一个简单的php分页类代码(转载)

    入门级php分页类 原文地址:http://www.xfcodes.com/php/fenye/3608.htm 时间:2015-12-16 20:52:00来源:网络 php分页类. 复制代码代码如 ...

  4. 一个基类Person的多个派生类 代码参考

    #include <iostream> #include <cstring> using namespace std; class Person { protected: ch ...

  5. 设计带构造函数的Dog类 代码参考

    #include <iostream> #include <string> using namespace std; class Dog { private: string n ...

  6. 设计Dog类 代码参考

    #include <iostream> #include <string> using namespace std; class Dog { private: string n ...

  7. 设计Person类 代码参考

    #include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...

  8. 设计并测试Trapezium类 代码参考

    #include <iostream> using namespace std; class Trapezium { private: int x1,y1,x2,y2,x3,y3,x4,y ...

  9. 设计Weekday类 代码参考

    #include <iostream> using namespace std; class Weekday { private: int num; public: void SetDay ...

随机推荐

  1. 「译」Graal JIT编译器是如何工作的

    原文Understanding How Graal Works - a Java JIT Compiler Written in Java,讲了jvmci和ideal graph的基本概念以及一些优化 ...

  2. 看直播 csust oj

    看直播 Description 小明喜欢看直播,他订阅了很多主播,主播们有固定的直播时间 [Li, Ri] . 可是他网速只有2M,不能同时播放两个直播,所以同一时间只能看一个直播. 并且他只会去看能 ...

  3. Cookie什么?Cookie和Session防御怎么做?

    Cookie什么?Cookie和Session防御怎么做? Cookie的概念 Cookie,复数形态Cookies,中文名称为小型文本文件.指某些网站为了辨别用户身份.进行session跟踪而储存在 ...

  4. 带你看看Java的锁(三)-CountDownLatch和CyclicBarrier

    带你看看Java中的锁CountDownLatch和CyclicBarrier 前言 基本介绍 使用和区别 核心源码分析 总结 前言 Java JUC包中的文章已经写了好几篇了,首先我花了5篇文章从源 ...

  5. ASP.NET Core on K8S学习之旅(12)Ingress

    本篇已加入<.NET Core on K8S学习实践系列文章索引>,可以点击查看更多容器化技术相关系列文章. 一.关于Ingress Kubernetes对外暴露Service主要有三种方 ...

  6. 嫌弃Apriori算法太慢?使用FP-growth算法让你的数据挖掘快到飞起

    本文始发于个人公众号:TechFlow,原创不易,求个关注 今天是机器学习专题的第20篇文章,我们来看看FP-growth算法. 这个算法挺冷门的,至少比Apriori算法冷门.很多数据挖掘的教材还会 ...

  7. vue 在main.js里使用vue实例

    可以用 Vue.prototype 比如 Vue.prototype.$indicator.close(); 关闭正在加载的动画

  8. HTML简单的伪装与造假

    利用浏览器制止台能简单的修改内容,致使其造成伪装. 打开网页控制台后,不要管那些眼花撩乱的代码,我们直接寻找控制台顶部的 Tab 栏 找到 Console 这个 Tab,点击它,把代码 documen ...

  9. jbpm4.4 发送邮件

    测了两天终于成功发送出邮件了,坑爹呢!原来一直用QQ邮箱发送,发现发送不了,提示要用ssl协议进行发送,后来换成了126邮箱,发送成功了!具体配置如下: jbpm定义文件 <?xml versi ...

  10. Xshell 与 Xftp 的安装与使用

    我们在日常工作中,不管是系统管理员.程序员.还是技术工程师,如果想登陆到 Linux 服务器,不可能总是跑到机房去工作,通常我们需要一个工具帮我们去做远程连接,这样我们只需要用笔记本电脑就可以连接到服 ...