青少年编程知识记录 codecoming

判断闰年

代码参考:

#include<iostream>   using namespace std;  //判断闰年的函数   int leap(int year){  	if((year%4!=0)||(year%100==0&&year%400!=0))  		return 0;  //0表示是平年  	else  		return 1; //1表示是闰年  }  int main()  {  	cout<<leap(2000)<<endl;  	cout<<leap(1000)<<endl;  	cout<<leap(1996)<<endl;  	cout<<leap(2012)<<endl;  	return 0;    }



(adsbygoogle = window.adsbygoogle || []).push({});

标签: 闰年

作者:亿万年的星光 分类:C++知识 浏览: