如图,rectime里面的时间怎样能显示成时分秒格式且间隔5分钟
1个回答
展开全部
#include<iostream.h>
class Time
{
int hour,minite,second;
Time(int a,int b,int c)
{
hour=a;minite=b;second=c;
}
Time()
{
hour=minite=second=1;
}
public:
void display()
{cout<<hour<<':'<<minite<<':'<<second<<endl;}
void increase()
{
second--;
if(second<0)
{second+=60;minite--;}
if(minite<=0)
{hour--;minite+=60;}
if(hour<1)
hour+=24;
}
void decrease()
{
second++;
if(second>=60)
{second-=60;minite++;}
if(minite>=60)
{hour++;minite-=60;}
if(hour>24)
hour-=24;
}
};
class Time
{
int hour,minite,second;
Time(int a,int b,int c)
{
hour=a;minite=b;second=c;
}
Time()
{
hour=minite=second=1;
}
public:
void display()
{cout<<hour<<':'<<minite<<':'<<second<<endl;}
void increase()
{
second--;
if(second<0)
{second+=60;minite--;}
if(minite<=0)
{hour--;minite+=60;}
if(hour<1)
hour+=24;
}
void decrease()
{
second++;
if(second>=60)
{second-=60;minite++;}
if(minite>=60)
{hour++;minite-=60;}
if(hour>24)
hour-=24;
}
};
追问
谢谢你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询