Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- //month# 1 2 3 4 5 6 7 # 8 9 10 11 12
- //days 31 28 31 30 31 30 31 # 31 30 31 30 31
- // (month < 8) and (month % 2 != 0) # (month >= 8) and (month % 2 == 0)
- // ((month < 8) and (month % 2 != 0)) or ((month >= 8) and (month % 2 == 0))
- int main()
- {
- int days{ 30 };
- int month{ 2 };
- int year{ 2021 };
- std::cout << "Enter year:\n";
- std::cin >> year;
- std::cout << "Enter month 1-12:\n";
- std::cin >> month;
- const bool isLeap{ (year % 400 == 0) or (year % 4 == 0) and (year % 100 != 0) };
- days += ((month < 8) and (month % 2 != 0) or (month >= 8) and (month % 2 == 0)) + (-2 * (month == 2) + isLeap);
- std::cout << "In month# " << month << " there are " << days << " days\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement