//整型、实型、指针、bool与 0 的比较
#include <iostream>
using namespace std;
int main()
{
bool flag = true; //布尔变量只有 0(flase)和 1(true)两种情况
if(flag)
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
int i = 1; //整型 i
if(i == 0)
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
float j =0.1; //实型 j
if((j>-0.000001) && (j<0.000001)) //判别是否为0, 这是逼近0.
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
int t = 1;
int* p = &t; //指针p
if(NULL == p) //指针p是否为空
{
cout<<"true"<<endl;
}else{
cout<<"flase"<<endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
bool flag = true; //布尔变量只有 0(flase)和 1(true)两种情况
if(flag)
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
int i = 1; //整型 i
if(i == 0)
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
float j =0.1; //实型 j
if((j>-0.000001) && (j<0.000001)) //判别是否为0, 这是逼近0.
{
cout<<"ture"<<endl;
}else{
cout<<"flase"<<endl;
}
int t = 1;
int* p = &t; //指针p
if(NULL == p) //指针p是否为空
{
cout<<"true"<<endl;
}else{
cout<<"flase"<<endl;
}
return 0;
}