c语言判断闰年1900—2000
时间: 2023-11-24 12:07:56 浏览: 35
判断闰年的方法是:能被4整除但不能被100整除的年份为普通闰年,能被400整除的为世纪闰年。因此,1900-2000年之间的闰年可以按照以下方法判断:
```c
#include <stdio.h>
int main() {
int year;
printf("请输入一个年份:");
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
printf("%d年是闰年\n", year);
} else {
printf("%d年不是闰年\n", year);
}
return 0;
}
```
相关问题
c语言判断闰年pta
以下是C语言判断闰年的代码示例:
```c
#include <stdio.h>
int main() {
int n, year;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
```
该代码通过输入测试组数n和n个年份y,判断每个年份y是否为闰年,若是则输出YES,否则输出NO。
c语言判断闰年流程图
判断闰年的方法是:能被4整除但不能被100整除,或者能被400整除的年份是闰年。
以下是C语言的判断闰年的代码示例:
```c
#include <stdio.h>
int main() {
int year;
printf("请输入一个年份:");
scanf("%d", &year);
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
printf("%d年是闰年\n", year);
} else {
printf("%d年不是闰年\n", year);
}
return 0;
}
```
以下是C语言的判断闰年的流程图示例:
![判断闰年的流程图](https://img-blog.csdn.net/20180419103212909?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfY2hpbmFfYw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/q/80/format/webp)