If语句的语法形式
if (表达式) 语句
例:if (x > y) cout << x;
if (表达式) 语句1 else 语句2
例:if (x > y) cout << x;
else cout << y;
if (表达式1)语句1
else if (表达式2) 语句2
else if (表达式3) 语句3
…
else 语句 n
#include <iostream>
using namespace std;
int main(){
int year;
bool isLeapYear;
cout<<"input the year:"<<endl;
cin>>year;
isLeapYear=((year%4==0&&year%100!=0)||year%400==0);
if(isLeapYear){
cout<<year<<" is a LeapYear"<<endl;
}else{
cout<<year<<" is not a LeapYear";
}
return 0;
}