您的位置:首页 > 其它

判断闰年 输出闰年

2016-09-22 21:26 357 查看
#include <stdio.h>

#include <stdlib.h> 

int LeapYear(int n){

if((n%400==0)||(n%100!=0)&&(n%4==0)){
return 1;} 
else{
return 0;
}

}

void main() {

int n;

printf("2000年到3000年之间所有的闰年如下:\n");

for(n=2000;n<=3000;n++){
if(LeapYear(n)==1)

{
printf("%d ",n);

}

}
printf("\n"); 
getch();

}

#include <stdio.h>

#include <stdlib.h>

int main(){
int n;

while (scanf("%d",&n)!=EOF){
if((n%400==0)||(n%100!=0)&&(n%4==0)){

printf("yes");


else

{
printf("no");
}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  闰年