今天看了微课的逻辑运算符部分,了解了关于它的知识:
逻辑运算符号:&&,||,!
运算结果为true(1) false(0)
&&与 两个数都为true则结果为true
||或 只要一个为true则结果为true
!非 true则false
优先级!>算术运算>关系运算>&&>||
逻辑值:非0为true,0为false
判断闰年:
#include<iostream>
using namespace std;
int main()
{
int y;
bool f;
cin >> y;
f = ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0);
cout << f << endl;
system("pause");
return 0;
}