#include <iostream>
using namespace std;
class Time{
int hour;
int min;
int sec;
public:
Time(int a,int b,int c)
{
hour=a;
min=b;
sec=c;
}
void show()
{
cout << '\r';
if(hour<10)
cout << 0;
cout << hour << ':';
if(min<10)
cout << 0;
cout << min << ':';
if(sec<10)
cout << 0;
cout << sec << flush;
}
void tick()
{
long t=time(NULL);
while(time(NULL)==t);
if(--sec<=0)
{
sec=59;
if(--min<=0)
{
min=59;
if(--hour<=0)
hour=23;
}
}
}
void run()
{
for(;;)
{
tick();
show();
}
}
};
int main()
{
int a=0,b=0,c=0;
cout << "请输入时间:" << endl;
cout<< "hour:";
cin >> a;
cout<<"minute:";
cin >> b;
cout<< "second:";
cin >> c;
Time t(a,b,c);
t.run();
}
c++源代码:倒计时(输入时 分 妙)
最新推荐文章于 2024-08-19 20:55:57 发布