时间管理器⏰v0.1.5代码+⭐完整解析

本文详细解析了一个C++实现的时间管理器代码,包括关键头文件的用途,如bits/stdc++.h、ctime和cstdio,以及四个自定义函数:delay()、naozhong()、shijian()和daojishi()的功能。主程序提供了用户选择不同时间管理功能的选项,如显示时间、设置闹钟和倒计时。
摘要由CSDN通过智能技术生成

目录

前言

代码

解析

1.头文件

(1)#include

(2)#include和#include

(3)#include

(4)#include

2.自定义函数delay( )

3.自定义函数naozhong( )

4.自定义函数shijian( )

5.自定义函数daojishi( ) 

6.主程序

尾言


前言

前几天我不是造了个时间管理器的代码吗?(手都快寄了)

我心想:这个这么难的代码,就让我来解析一下吧

代码

#include<bits/stdc++.h>
#include<ctime>
#include<cstdio>
#include<windows.h>
#include<time.h>
using namespace std;
void delay(int second){
	time_t start_time,cur_time;
	time(&start_time);
	do{
	    time(&cur_time);
	} 
	while((cur_time - start_time) < second);
}
void naozhong()
{
	system("title 闹钟");
	int a,b,c;
	cout<<"请输入一个时间(格式:时 分 秒)";
	cin>>a>>b>>c;
	system("cls");
	cout<<"规定时间:"<<a<<":"<<b<<":"<<c<<endl; 
	while(1){
		time_t nowtime;
		struct tm* p;
		time(&nowtime);
		p = localtime(&nowtime);
		cout<<"规定时间:"<<a<<":"<<b<<":"<<c<<endl; 
		int x,y,z;
		x=p->tm_hour;
		y=p->tm_min;
		z=p->tm_sec;
		printf("当前时间:%02d:%02d:%02d\n",p->tm_hour,p->tm_min,p->tm_sec);
		if(p->tm_hour==a){
			if(p->tm_min==b){
				if(p->tm_sec==c){
					cout<<"时间到!";
				}
			}
		}
		system("cls");
	}
}
void shijian(){
	time_t nowtime;
	struct tm* p;
	time(&nowtime);
	p = localtime(&nowtime);
	while(1){
		time_t nowtime;
		struct tm* p;
		time(&nowtime);
		p = localtime(&nowtime);
		cout<<p->tm_hour<<":"<<p->tm_min<<":"<<p->tm_sec;
		system("cls");
	}
}
void daojishi(){
	int j,k,l;
	cout<<&
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值