目录
前言
前几天我不是造了个时间管理器的代码吗?(手都快寄了)
我心想:这个
这么难的代码,就让我来解析一下吧
代码
#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<<&