请问一下老师,怎么用VC6.0编写出一个模拟时钟和数字时钟为一体的程序
1个回答
展开全部
#include<iostream>
#include<windows.h>
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<<h<<':'<<m<<':'<<s<<" ";
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;
}
#include<windows.h>
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<<h<<':'<<m<<':'<<s<<" ";
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;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询