C++定义一个时间计时类
来源:互联网 发布:尼康d810调焦软件 编辑:程序博客网 时间:2024/06/06 04:36
#include<iostream>#include<stdio.h>#include<Windows.h>//----------------------------------------定义一个自动显时的类-------------------------using namespace std;class timer{ //计时类 int hour; //小时 int minute; //分钟 int second; //秒public: void set(int h, int m, int s);//设置当前时间 void caculate(); //计时 void show(); //显示时间};//-------------------------------------设置时间方法------------------------------------void timer::set(int h, int m, int s){ hour = h; minute = m; second = s; if (h > 23 || h < 0) { cout << "h时间有误" << endl; } if (m > 59 || m < 0) { cout << "m时间有误" << endl; } if (s > 59 || s < 0) { cout << "s时间有误" << endl; }}//--------------------------------------设置计时方法------------------------------------void timer::caculate(){ Sleep(1000); second++; if (second>59){ minute++; second = 0; } if (minute > 59){ hour++; minute = 0; } if (hour > 23){ hour = 0; }}//----------------------------------------设置显示时间的类---------------------------------void timer::show(){ system("cls"); cout << hour << ":" << minute << ":" << second << endl;}int main1(){ cout << "请输入当前时间(时 分 秒)" << endl; int a, b, c; cin >> a >> b >> c; timer t; t.set(a, b, c); while (1){ t.caculate(); t.show(); } return 0;}
阅读全文
0 0
- C++定义一个时间计时类
- c 计时
- 一个时间处理的类
- 设计一个时间类Time
- C#自定义一个时间类
- Unity3D脚本:C#计时类脚本
- 计时类
- linux C语言 计时
- linux C语言 计时
- C语言计时函数
- 【c++】计时函数
- c计时函数
- C语言计时函数
- C/C++计时函数
- C语言计时函数
- C/C++ 计时
- 【C/C++】计时函数比较
- 【C/C++】计时函数比较
- 最长上升子序列模板(LIS)
- springboot(十四)使用spring retry
- MFC中单选按钮(Radio Button)的简单使用
- HDU 1950 Bridging signals
- 取得request对象中所有的参数值并生成一个相应的对象返回
- C++定义一个时间计时类
- 2017多校5 1011 Rikka with Competition
- OpenGL ES应用开发实践指南(android 卷)笔记 第五章1
- Caffe学习:使用pycaffe读取mean.binaryproto文件参数
- 谈谈react操作onMouseEnter、onMouseLeave结合css里的hover
- Mac 下验证下载文件的 MD5/SHA1/SHA256
- Android开源库整理(2)
- Android开发学习(7)ListView
- CSS3理解position属性