21世纪的闰年

来源:互联网 发布:华南师范大学网络公选 编辑:程序博客网 时间:2024/04/29 01:30
#include<iostream>#include<iomanip>using namespace std;int main(void){cout<<"21世纪的闰年:"<<endl; int counter=0;for(int year=2001;year<=2100;year++){   bool LeapYear=true;    if(year%4==0)    {        if(year%100==0&&year%400!=0)        {            LeapYear=false;        }        else        LeapYear=true;    }    else    LeapYear=false;    if(LeapYear)    {        cout<<setw(5)<<year;        counter++;    }    if(counter%5==0)    cout<<endl;}cout<<endl;return 0;}
0 0
原创粉丝点击