当前位置:网站首页>Common techniques for handling dates

Common techniques for handling dates

2022-06-11 10:23:00 [email protected]


int a[2][13]={
   {0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
}; // Array records 12 Days of months   a[0][m] Corresponding to ordinary years ,a[1][m] Corresponding leap year 



int leapyear(int y)// Judge that leap years can be 400 to be divisible by || Can be 4 Divisible but not divided by 100 to be divisible by 
{
    return y%4==0&&y%100!=0||y%400==0;
}


int days(int y,int m)// return y year m Days of the month 
{
    return a[leapyear(y)][m];
}

原网站

版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203012231369205.html