#include <stido.h>
void main()
{
  int a,b,d=241;
  a=d/100%9;
  b=(-1)&&(-1);
  printf("%d,%d\n",a,b);
}

为什么答案是2,1???怎么算的?

 

代码
#include <iostream> 
void main() 

   
int a,b,d=241
   a
=d/100%9
   
/////  d/100 =241 /100 =2;
   
///////2%9 =2
   
////// 所以a为2
////// 还有整型计算不带小数.

   b
=(-1)&&(-1); 
   
/////////&& 操作符号,两边都不为0,所以为真,即 1;下面添加一个c,一边为0,即为假的时候,&&
   
/////////操作后就为 假 即0 了。 -1为ture,结果为ture 输出则为1
   int c =(-1)&&(0);
   printf(
"%d,%d,%d\n",a,b,c); 
}

 

 

相关文章:

  • 2022-12-23
  • 2021-12-29
  • 2022-02-22
  • 2021-11-02
  • 2021-07-19
  • 2021-09-28
  • 2021-11-13
猜你喜欢
  • 2021-11-04
  • 2021-06-12
  • 2022-12-23
  • 2022-01-08
  • 2021-06-27
  • 2021-09-20
  • 2022-12-23
相关资源
相似解决方案