判断是否是闰年:
四年一闰,百年不闰,四百年再闰
#include<stdio.h> #include<stdlib.h> int leap(int year) { int ret = 0;; if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) { return 1; } else { return -1; } } int main() { int Year = 0; printf("please input the year:\n"); scanf("%d", &Year); int ret = leap(Year); /*将调用得到的函数值返回到ret中*/ if (ret == 1) { printf("%d is leap year!", Year); } else { printf("%d is not leap year!", Year); } system("pause"); return 0; }