class Time
{
public:
int hour;
int minute;
int second;
Time()
{
int totalSeconds=time(0);
int currentSecond=totalSeconds%60;
int totalMinutes=totalSeconds/60;
int totalMinute=int totalMinutes%60;
int totalHours=totalMinutes/60;
int currentHour=totallHours%24;
cout<<"Current time is"<return 0;
}
Time (int second)
{
cin>>second;
int totalSeconds=second;
int currentSecond=totalSeconds%60;
int totalMinutes=totalSeconds/60;
int totalMinute=int totalMinutes%60;
int totalHours=totalMinutes/60;
int currentHour=totallHours%24;
cout<<"New time is 1970 year 1.1"<return 0;
}
Time(int hour,int minute,int second)
{
cin>>hour>>minute>>second;
cout<<"The time is"<return 0;
}
int get_hour()
{
return hour;
}
int get_minute()
{
return minute;
}
int get_second()
{
return second;
}
setTime(int elapseTime)
{
int totalSeconds=time(0);
int currentSecond=totalSeconds%60;
int totalMinutes=totalSeconds/60;
int totalMinute=int totalMinutes%60;
int totalHours=totalMinutes/60;
int currentHour=totallHours%24;
int a=elapseTime;
int da=a%60;
int b=a/60;
int db=int b%60;
int c=b/60;
int dc=c%24;
cout<<"Current time is"<<(currentHour+dc)<<":"<<(currentMinute+db)<<":"<<(currentSecond+da)<return 0;
}
};
int main()
{
cout<
return 0;
}
#include <iostream>
using namespace std;
class Time
{
private:
int hour;
int minute;
int second;
void sot(int seconds)
{
second = seconds % 60;
int totalMinutes = seconds / 60;
minute = totalMinutes % 60;
int totalHours = totalMinutes / 60 + 8; //东8区
hour = totalHours % 24;
}
public:
Time()
{
sot(time(0));
}
Time(int second)
{
sot(second);
}
Time(int hour, int minute, int second) : hour(hour), minute(minute), second(second)
{
}
int get_hour()
{
return hour;
}
int get_minute()
{
return minute;
}
int get_second()
{
return second;
}
void setTime(int elapseTime)
{
second += elapseTime;
minute += second / 60;
second %= 60;
hour += minute / 60;
minute %= 60;
hour %= 24;
}
friend ostream &operator<<(ostream &out, Time &time)
{
out << time.hour << ":" << time.minute << ":" << time.second;
return out;
}
};
int main()
{
Time time1;
cout << "Current time is: " << time1 << endl;
Time time2(555550);
cout << "New time is 1970 year 1.1: " << time2 << endl;
time2.setTime(1200);
cout << "The time is: " << time2 << endl;
return 0;
}
程序运行不起来还是部分功能没实现?