Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int examHour, examMinute, arrivalHour, arrivalMinute;
- cin >> examHour >> examMinute >> arrivalHour >> arrivalMinute;
- int totalExamTime;
- int totalArrivalTime;
- int secondsResult;
- totalExamTime = (examHour * 60 * 60) + (examMinute * 60);
- totalArrivalTime = (arrivalHour * 60 * 60) + (arrivalMinute * 60);
- if (totalArrivalTime == totalExamTime || totalExamTime - totalArrivalTime >= 0 && totalExamTime - totalArrivalTime <= 1800)
- {
- secondsResult = (totalExamTime - totalArrivalTime) / 60;
- cout << "On time" << endl;
- cout << secondsResult << " minutes before the start";
- }
- else if (totalArrivalTime > totalExamTime)
- {
- cout << "Late" << endl;
- secondsResult = totalArrivalTime - totalExamTime;
- secondsResult = secondsResult / 60;
- if (secondsResult <= 59)
- {
- cout << secondsResult << " minutes after the start";
- }
- else if (secondsResult > 59)
- {
- if (secondsResult % 60 < 10)
- {
- cout << secondsResult / 60 << ":0" << secondsResult % 60 << " hours after the start";
- }
- else
- {
- cout << secondsResult / 60 << ':' << secondsResult % 60 << " hours after the start";
- }
- }
- }
- else if (totalExamTime > totalArrivalTime)
- {
- cout << "Early" << endl;
- secondsResult = totalExamTime - totalArrivalTime;
- secondsResult = secondsResult / 60;
- if (secondsResult <= 59)
- {
- cout << secondsResult << " minutes before the start";
- }
- else if (secondsResult > 59)
- {
- if (secondsResult % 60 < 10)
- {
- cout << secondsResult / 60 << ":0" << secondsResult % 60 << " hours before the start";
- }
- else
- {
- cout << secondsResult / 60 << ':' << secondsResult % 60 << " hours before the start";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement