Ad
Code
Diff
  • using System;
    
    public class LeapYears
    {
      // Works but hurts
      public static bool IsLeapYear(int y) => (y % 400 == 0) ? true : (y % 100 == 0 && y % 400 != 0) ? false : (y % 4 == 0 && y % 100 != 0) ? true : false;
    }
    • using System;
    • public class LeapYears
    • {
    • public static bool IsLeapYear(int year)
    • {
    • if (year % 400 == 0) return true;
    • if (year % 100 == 0 && year % 400 != 0) return false;
    • if (year % 4 == 0 && year % 100 != 0) return true;
    • return false;
    • }
    • // Works but hurts
    • public static bool IsLeapYear(int y) => (y % 400 == 0) ? true : (y % 100 == 0 && y % 400 != 0) ? false : (y % 4 == 0 && y % 100 != 0) ? true : false;
    • }
using System;

public class LeapYears
{
  public static bool IsLeapYear(int year)
  {
    if (year % 400 == 0) return true;
    if (year % 100 == 0 && year % 400 != 0) return false;
    if (year % 4 == 0 && year % 100 != 0) return true;
    return false;
  }
}