avr39ripe

SBUdaysInMonth

Jun 20th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. //1     2       3   4   5   6   7   |   8   9   10  11  12
  4. //31    30(28)  31  30  31  30  31  |   31  30  31  30  31
  5.  
  6. //30 + ((month < 8) and (month % 2 !=0 ) or (month >= 8) and (month % 2 ==0)) + ((-2) * (month == 2))
  7.  
  8.  
  9. //==
  10. //!=
  11. //>
  12. //<
  13. //>=
  14. //<=
  15. //!
  16. //and
  17. //or
  18.  
  19. int main()
  20. {
  21.     //int month{ 1 };
  22.     int daysInMonth{0};
  23.     int year{ 2020 };
  24.  
  25.     //((year % 400 == 0 ) or (year % 4 == 0 )) and ( year % 100 != 0)
  26.     for (int month{ 1 }; month <= 12; ++month)
  27.     {
  28.         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)));
  29.         std::cout << daysInMonth << ' ';
  30.     }
  31.     std::cout << '\n';
  32. }
Advertisement
Add Comment
Please, Sign In to add comment