程序:
#include <iostream.h>
void main()
{
int year;
cout<<"please input the year"<<endl;
cin>>year;
if(year%100==0)
{if(year%400==0)
cout<<"It is a leap year!"<<endl;
else
cout<<"It is not a leap year!"<<endl;
}
else
{if(year%4==0)
cout<<"It is a leap year!"<<endl;
else
cout<<"It is not a leap year"<<endl;
}
}
好像这是个入门级作品哦,一开始把判断条件搞错,还一直在怀疑1900年为什么是闰年,呵呵。