Сложение времени. :)
Формат записи и вывода на экран один и тот же.
//------------------------------------------------------------------------------------------------
#include <iostream>
#include <conio.h>
using namespace std;
struct Time
{
unsigned int hour;
unsigned int min;
unsigned int sec;
};
unsigned int convert (Time, Time);
Time convert(unsigned int);
//------------------------------------
int main()
{
Time time1, time2, time3;
char ch=':';
cout<<"Enter time1 in format: [23:15:59] : ";
cin>>time1.hour>>ch>>time1.min>>ch>>time1.sec;
cout<<"Enter time2 in format [same format]: ";
cin>>time2.hour>>ch>>time2.min>>ch>>time2.sec;
time3 = convert(convert(time1, time2));
cout<<"Itogovoe time: "<<time3.hour<<ch<<time3.min<<ch<<time3.sec<<endl;
getch();
return 0;
}
//------------------------------------------------
unsigned int convert (Time t1, Time t2)
{
unsigned int a=t1.sec+t1.min*60+t1.hour*3600;
unsigned int b=t2.sec+t2.min*60+t2.hour*3600;
return a+b;
}
//-----------------------------------------------
Time convert(unsigned secund)
{
Time t3;
t3.hour=secund/3600;
t3.min=(secund%3600)/60;
t3.sec=secund-t3.hour*3600-t3.min*60;
return t3;
}
//------------------------------------------------------------------------------------------------