感觉就for有些别扭。对了也可以用其他方法l
#includ<stdio.h>
int main(){
int year=0;
printf("请输入年份:%d\n",year);
scanf("%d\n",&year);
for(;(year%4==0&&year%100!=0)||year%400==0;){
printf("%d:是闰年\n",year);
}
printf("不是闰年");
return 0;
}
#include<stdio.h>
int main() {
int year = 0;
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;
}
#include<stdio.h>
int main() {
for (int year = 2000; year <= 2500; year++) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
printf("%d:是闰年\n",year);
}
else
{
printf("%d:不是闰年\n",year);
}
}
}
标签:判断,闰年,int,year,C语言,printf,year%,main
From: https://blog.csdn.net/2301_81990803/article/details/136874357