1个回答
展开全部
#include <iostream>
using namespace std;
class Time
{
private:
int h;
int m;
int s;
int sr;
public:
Time(){}
Time(int a,int b,int c)
{
h = a;
m = b;
s = c;
}
Time(int a)
{
sr = a;
}
void showsc()
{
sr = h * 3600 + m * 60 + s;
cout<<sr<<endl;
}
void showti()
{
h = sr / 3600;
m = (sr - (h * 3600)) / 60;
s = sr - h * 3600 - m * 60;
if(h < 10)
cout<<"0";
cout<<h<<":";
if(m < 10)
cout<<"0";
cout<<m<<":";
if(s < 10)
cout<<"0";
cout<<s<<endl;
}
};
int main()
{
Time t;
int a,b,c,d;
cin>>a;
cin.get();
cin>>b;
cin.get();
cin>>c;
t = Time(a,b,c);
t.showsc();
cin>>d;
t = Time(d);
t.showti();
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询