考级辅导穿插
原题链接:67324.4.0U5笔记合集2025-09-06 16:54:17
发布于:江苏
cout<<sqrt(81) << endl; //9
int n; cin>>n;
if (sqrt(n) * sqrt(n) == n) cout <<"yes";
else cout <<"no";
cout << pow(2, 10) << endl; //1024
floor(3.4) = 3
ceil(3.4) = 4
ceil(4.0) = 4
1 B = 8 bit
1 KB = 1024 Byte
1 MB
1 GB
1 TB
!>&&>||
cout << (45 || 6 && 0) ; //1
拆分or拼凑
38
32 16 8 4 2 1
1 0 0 1 1 0
180
128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 0
110 1011
32+64 8021
96+11
& : 按位与
| : 按位或
~ : 按位取反
<< : 按位左移
>> : 按位右移
^ : 按位异或
// cout << (13 && 6) << endl; //1
cout << (13 & 6) << endl; //4
cout << (13 | 6) << endl; //15
cout << (13 ^ 6) << endl; //11
/*
1101
& 0110
0100
1101
| 0110
1111=15
1101
^ 0110
1011=11 (加法或者减法)
*/
>>:
for (int i=1; i<=2048; i<<=1){
cout << i << endl;
}
// 1100 >> 1
// 110
// 11
// 1
// 0
~:
cout << (~5) << endl; //-6
/*
cout << (~9) << endl; //-10
cout << (~99) << endl; //-100
cout << (~-5) << endl; //4
cout << (~-50) << endl; //49
cout << (~0) << endl; //-1
~(n) = -(n+1)
*/
机器码,二进制码
所有数字都是补码的形式存储的, 但是, 正数的三码相同
5
原码:0000 0101
反码:0000 0101
补码:0000 0101
-1:符号位1表示负数, 0表示正数
原码:1000 0001
反码:1111 1110 : 符号位不变, 其他位取反
补码:1111 1111: = 反码+1
5
原码:0000 0101
取反~(大LM)
1111 1010 (负数, 补码)
1111 1001 反码
1000 0110 原码 (-6)
cout << sizeof (int) << endl; //4Byte
cout << sizeof (long) << endl; //4Byte 因系统而异
cout << sizeof (long long) << endl; //8Byte
cout << sizeof (short) << endl; //2Byte
cout << sizeof (char) << endl; //1Byte
cout << sizeof (double) << endl; //8Byte
cout << sizeof (float) << endl; //4Byte
cout << sizeof (bool) << endl; //1Byte
这里空空如也
有帮助,赞一个