Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Решение с тернарен оператор:
- #include <iostream>
- #include <iomanip>
- #include <string>
- using namespace std;
- int main() {
- int examHour, examMinutes, studentHour, studentMinutes;
- cin >> examHour >> examMinutes >> studentHour >> studentMinutes;
- int totalExamMinutes = examHour * 60 + examMinutes;
- int totalStudentMinutes = studentHour * 60 + studentMinutes;
- int diff = totalExamMinutes - totalStudentMinutes;
- cout << (diff < 0 ? "Late" : diff > 30 ? "Early" : "On time") << endl;
- if (diff != 0) {
- if (abs(diff) < 60) {
- cout << abs(diff) << " minutes " << (diff > 0 ? "before" : "after") << " the start" << endl;
- }
- else {
- cout << (abs(diff) / 60) << ':' << setw(2) << setfill('0') << abs(diff) % 60 << " hours " << (diff > 0 ? "before" : "after") << " the start" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement