编程基本功——判断闰年

一、分析

    闰年特点:该年份能被4整除,但不能被100整除

                  该年份能被4整除,又能被400整除

二、源码

   1: #include "stdio.h"
   2:  
   3: int main()
   4: {
   5:     int nYear;
   6:     printf("Please input a year:\n");
   7:     scanf("%d", &nYear);
   8:  
   9:     if ((nYear % 4 == 0 && nYear % 100 != 0) || (nYear % 400 == 0))
  10:     {
  11:         printf("%d is a leap year!\n", nYear);
  12:     }
  13:     else
  14:     {
  15:         printf("%d is not a leap year!\n", nYear);
  16:     }
  17:     getchar();
  18:     return 0;
  19: }
原文地址:https://www.cnblogs.com/steven_oyj/p/1742466.html