C 语言实例 - 判断闰年

C 语言教程 · 2019-02-20 17:27:02

用户输入年份,判断该年份是否为闰年。

实例

#include <stdio.h> int main() { int year; printf("输入年份: "); scanf("%d",&year); if(year%4 == 0) { if( year%100 == 0) { // 这里如果被 400 整数是闰年 if ( year%400 == 0) printf("%d 是闰年", year); else printf("%d 不是闰年", year); } else printf("%d 是闰年", year ); } else printf("%d 不是闰年", year); return 0; }

运行结果:

输入年份: 1990
1990 不是闰

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

How Great Decisions Get Made

How Great Decisions Get Made

Maruska, Don / 2006-2 / $ 20.28

All too often, solving tough work issues can become a tug of war as clashing departments, priorities, personality styles, and other concerns threaten to destroy any possibility of a successful conclus......一起来看看 《How Great Decisions Get Made》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具