Napisałem dodawanie, to było proste:
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
// should be: 21:59:2
int rH(0), rM(0), rS(0);
int h1 = 12, m1 = 34, s1 = 56;
int h2 = 9, m2 = 24, s2 = 6;
rS = s1 + s2;
while (rS >= 60)
{
rS -= 60;
rM++;
}
rM += m1 + m2;
while (rM >= 60)
{
rM -= 60;
rH++;
}
rH += h1 + h2;
while (rH >= 24)
{
rS -= 24;
}
cout << rH << " " << rM << " " << rS << " " << "\n";
return 0;
}
Mam jednak problem z odejmowaniem 2 godzi, na takiej samej zasadzie. Mógłby ktoś pomóc?