Back to General discussions forum
using namespace std;
int main() { ifstream input("input.txt"); ofstream output("output.txt");
int a;
input>>a;
for(int i(0); i < a; i++)
{
int day1, hour1, minuty1, second1, day2, hour2, minuty2, second2, result1, result2;
input>>day1>>hour1>>minuty1>>second1>>day2>>hour2>>minuty2>>second2;
result1 = (day1 * 24 * 60 * 60) + (hour1 * 60 * 60) + (minuty1 * 60) + second1;
result2 = (day2 * 24 * 60 * 60) + (hour2 * 60 * 60) + (minuty2 * 60) + second2;
result2 -= result1;
day2 = result2/60/60/24;
hour2 = (result2/60/60) - (day2 * 24);
minuty2 = (result2/60) - (day2 * 24 * 60) - (hour2 * 60);
second2 = result2 - (day2 * 24 * 60 * 60) - (hour2 * 60 * 60) - (minuty2 * 60);
output<<"("<<" "<<day2<<" "<<hour2<<" "<<minuty2<<" "<<second2<<") ";
}
return 0;
}