C++定义的意思?

来源:百度知道 编辑:UC知道 时间:2024/05/05 22:03:31
#include<iostream>

using namespace std;
int main()
{
int year;
bool IsLeapYear;//这样定义是什么意思?
cout<<"Enter the year";
cin>>year;
IsLeapYear = ((year % 4==0&&year%100!=0)||year%400==0);
if(IsLeapYear)
cout<<"is a lear year"<<endl;
else
cout<<"is not a lear year"<<endl;
}

bool IsLeapYear;//定义一个布尔变量,用来存储对或错的结果。

bool是一个类型,值可以是 (真,假)
这是个算润年的程序,
如果year是闰年,((year % 4==0&&year%100!=0)||year%400==0)计算之后得true(真)赋值给IsLeapYear

bool类型 变量名IsLeapYear
true为1 false为0