菜鸟一枚,为了观察区别,特地运行了下面几个语句

 

 1 /*阅读程序回答问题,
 2 1.bool类型的false对应数值?true呢?
 3 2.非0整数对应bool型的?0呢? 
 4  */ 
 5 #include<iostream>
 6 #include<cstring>
 7 using namespace std;
 8 int main(){
 9     cout<<(2>1)<<(2==1)<<endl;
10      bool b=1<2;cout<<b<<endl;
11      bool c=3;cout<<c<<endl;
12     bool d=-3;cout<<d<<endl;
13      int e=3;cout<<e<<endl;
14      bool f=1;cout<<sizeof(f)<<endl;
15      if (5) cout<<"5  true"<<endl;
16      if (-5) cout<<"-5  true"<<endl;
17      if (0) cout<<"0 is ?"<<endl;
18      return 0;
19 }
View Code

相关文章:

  • 2021-07-03
  • 2021-09-24
  • 2021-06-06
  • 2022-12-23
  • 2021-06-09
  • 2022-01-31
  • 2022-12-23
猜你喜欢
  • 2021-06-08
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
相关资源
相似解决方案