当前位置:网站首页>Pta:6-71 clock simulation
Pta:6-71 clock simulation
2022-06-23 04:37:00 【Sy_ Faker】
One Time class , Data members sometimes 、 branch 、 second . Request analog stopwatch , One second at a time , full 60 Second carry , The second starts counting from zero . full 60 Fractional carry , Minutes are counted from zero . When the output 、 The value of minutes and seconds .( Use overload ++ Operator implementation )
Time class definition :
class MyTime
Sample test procedure :
/* Please fill in the answer here */
int main()
{
MyTime t1,t2(23,59,59),t3;
cin>>t3;
++t1;
cout<<t1<<endl;
++t2;
cout<<t2<<endl;
++t3;
cout<<t3<<endl;
return 0;
}
sample input :
12 35 59
sample output :
0:0:1
0:0:0
12:36:0
The main contents are : Constructors 、 heavy load ++ And input / output operators 、this The pointer
#include<iostream>
using namespace std;
class MyTime
{
int hour;
int mintue;
int second;
public:
MyTime()
{
hour=0;
mintue=0;
second=0;
}
MyTime(int a,int b,int c)
{
hour=a;
mintue=b;
second=c;
}
MyTime operator ++()
{
this->second++;
if(this->second>=60)
{
this->second=0;
this->mintue++;
}
if(this->mintue>=60)
{
this->mintue=0;
this->hour++;
}
if(this->hour>=24)
{
this->hour=0;
}
}
friend istream& operator >>(istream&in,MyTime &t)
{
in>>t.hour>>t.mintue>>t.second;
return in;
}
friend ostream& operator <<(ostream&os,MyTime &t)
{
os<<t.hour<<":"<<t.mintue<<":"<<t.second;
}
};
边栏推荐
- OpenJudge NOI 1.13 50:数根
- Redis启动有问题
- Mobile terminal city list sorting JS plug-in vertitylist js
- PTA:7-60 宠物的生长
- How to make the page number start from the specified page in word
- Photoshop PS viewing pixel coordinates, pixel colors, pixel HSB colors
- Introduction to deep learning
- [deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime
- Implementation of VGA protocol based on FPGA
- 离线数仓建模中常见的概念-术语
猜你喜欢
![[multimode] unimo](/img/a5/a857e20e1432ef3623527c8655a49a.png)
[multimode] unimo

Leetcode 1208. 尽可能使字符串相等(终于解决,晚安)

JD cloud distributed database stardb won the "stability practice pioneer" of China Academy of information technology

What are the characteristics of SRM supplier management system developed by manufacturing enterprises

什么是元数据

x64dbg 基本使用技巧

flutter系列之:flutter中的Wrap

Particle animation background login page particles js

How node+express operates cookies

Leetcode 1208. Try to make the strings equal as much as possible (finally solved, good night)
随机推荐
Introduction and use of MySQL view
浅析2022年物联网现状
距离度量 —— 余弦距离(Cosine Distance)
大一学生课设c——服装管理系统
PTA: Simulation Implementation of 7-87 set (class template)
2022年烷基化工艺考题及模拟考试
Tables de recherche statiques et tables de recherche statiques
虫子 日期类 上 太子语言
离线数仓建模中常见的概念-术语
x24Cxx系列EEPROM芯片C语言通用读写程序
PTA: Simulation Implementation of 7-86 set (function template)
Sequence table lookup
What are the characteristics of SRM supplier management system developed by manufacturing enterprises
P1363 幻象迷宫(dfs)
摆烂LuoGu刷题记
P1363 phantom maze (DFS)
How to ensure application security
Latest programming language rankings
Sessions and Daemons
Zhongang Mining: the demand for fluorite in the new energy and new material industry chain has increased greatly