请问一下老师,怎么用VC6.0编写出一个模拟时钟和数字时钟为一体的程序

2025-04-16 03:52:31
推荐回答(1个)
回答1:

#include
#include
using namespace std;
class Clock{
public:
Clock(short h=0,short m=0,short s=0):h(h),m(m),s(s){
}
void displayTime();
private:
short h;
short m;
short s;
};void Clock::displayTime(){
while(true){
cout<Sleep(1000);
cout<<'\r';
if(!(s=++s%60))
if(!(m=++m%60))
h=++h%24;
}
} int main()
{
Clock A(23,59,55);
A.displayTime();
return 0;
}