习题1-7 年份 解题报告

来源:互联网 发布:过五如何清理数据 编辑:程序博客网 时间:2024/05/18 00:52

题目:
这里写图片描述

代码:

#include <stdio.h>#include <stdlib.h>int main(){    int n;    scanf("%d",&n);    if(n%4==0 && n%100!=0 || n%400==0)    {        printf("yes\n");    }    else    {        printf("no\n");    }    return 0;}

解析:
1、闰年的判断条件为能被4整除且不能被100整除或者能被400整除。
2、运用逻辑表达式可以理清逻辑关系。

0 0
原创粉丝点击