qfedu-basic-level/day6/d7.cpp

19 lines
578 B
C++
Raw Normal View History

2023-06-19 15:25:02 +08:00
/*
01 10
1
-9 8, 10 -11
*/
2023-06-19 15:23:37 +08:00
#include <iostream>
using namespace std;
int main()
{
int n = 10;
cout << "~10 = " << ~n << endl; // -11 : ~ 位非运算符: 二进制取反: 0000 1010 => 1111 0101 => -11
n = -9;
cout << "~(-9) = " << ~n << endl; // 8 : ~ 位非运算符: 二进制取反: 1000 1001 => 0111 0110 => 8
return 0;
}