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