一、
1.先定义一个变量year,将输入的变量存放到year中
2.验证year是否满足能被四整除而不能被一百整除或者能被四百整除
二、
三、
#include<iostream>
using namespace std;
int main()
{
int year;
bool isrunnian;
cout<<"年份是:";
cin>>year;
isrunnian=((year%4==0&&year%100!=0)||(year%400==0));
if(isrunnian)
cout<<year<<"是一个闰年"<<endl;
else
cout<<year<<"不是一个闰年"<<endl;
return 0;
}
四、
#include<iostream>
using namespace std;
int main()
{
int year;
bool isrunnian;
cout<<"年份是:";
cin>>year;
isrunnian=((year%4==0&&year%100!=0)||(year%400==0));
if(isrunnian)
cout<<year<<"是一个闰年"<<endl;
else
cout<<year<<"不是一个闰年"<<endl;
return 0;
}
标签:isrunnian,cout,int,第三天,year,year%,打卡,整除 From: https://www.cnblogs.com/xscya/p/17319124.html