362
Cerința
Se consideră două evenimente a căror durată este exprimată fiecare prin câte trei numere naturale: ore (h), minute (m) şi secunde (s).
Exemplu
ore.in
3 35 55 2 40 8
ore.out
3: 35: 55 2: 40: 8 12955 9608 6: 16: 3
Explicație
În fișierul de intrare sunt detaliile referitoare la duratele cele două evenimente, iar suma lor este 6: 16: 3.
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ore.in");
ofstream fout("ore.out");
int main()
{
long long h1 , h2 , m1 , m2 , s1 , s2 , h , m , s;
fin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
fout << h1 << ": " << m1 << ": " << s1 << endl;
fout << h2 << ": " << m2 << ": " << s2 << endl;
long long x1 = h1 * 3600 + m1 * 60 + s1;
long long x2 = h2 * 3600 + m2 * 60 + s2;
fout << x1 << endl << x2 << endl;
long long y = x1 + x2;
s = y % 60;
m = ((y - 3) / 60) % 60;
y = (y - 3) / 60;
h = y / 60;
fout << h << ": " << m << ": " << s;
return 0;
}
Comentarii