如题所述
判断闰年的标准是:
1、能整除4且不能整除100 。
2、能整除400。
C代码如下:
using namespace std;
int main()
{
bool leapyear(int year);
int year;
bool leap;
cout<<"请输入年份:";
cin>>year;
getchar();
leap =leapyear(year);
if (leap)
cout<<year<<"is";
else
cout <<year <<"is not";
cout<<"a leap year"<<endl;
getchar();
return 0;
}bool leapyear(int year){
bool leap;
if (year%4==0)
{ if(year%100==0)
{ if(year%400==0)
leap=true;
else
leap=false;}
else
leap=true;
}
else
leap=false;return leap;}
温馨提示:答案为网友推荐,仅供参考
第1个回答 2017-07-06
我想问问,