Playground
在这里尽情试验你的代码!
初始化代码区
Caution
初始化代码区域主要用于引入头文件,此代码区域不可编辑。
#include <iostream>
using namespace std;
.setf(ios::boolalpha);
cout<< "初始化完成!" << endl; cout
试验代码区
Note
点击页面右上角ActiveActive按钮,等待按钮下方状态信息显示
Status:Kernel Connected kernel thebe.ipynb status changed to ready[idle]
即可编辑试验代码区的代码。编辑完成后请点击run allrun all钮执行代码。
算术运算
// 算术运算
<< (10 % 3) << endl;
cout << (10 % -3) << endl;
cout << (-10 % 3) << endl;
cout << (-10 % -3) << endl;
cout << (10 / 3) << endl;
cout << (10 / -3) << endl;
cout << (-10 / 3) << endl;
cout << (-10 / -3) << endl;
cout << (10 / 3 * 3) << endl; cout
关系运算
// 关系运算
<< ('A' < 'a') << endl;
cout << (true < false) << endl; cout
位运算
// 位运算
<< (0x73 & 0x01) << endl; // 0x73 == 0b 0111 0011
cout << (0x01 | 0x0F) << endl;
cout << (0x03 ^ 0x01) << endl;
cout << (0x01 << 4) << endl;
cout << (0x0F >> 2) << endl; cout
逻辑运算
// 逻辑运算
bool t = true, f = false;
<< (t and f) << endl;
cout << (t or f) << endl;
cout << (not f) << endl; cout
赋值运算
// 赋值运算
int a = 0;
<< (a = 1) << endl;
cout << (a = a + 1) << endl;
cout << (a += 1) << endl;
cout << (a *= 2) << endl;
cout << (a /= 2) << endl;
cout << (a %= 2) << endl;
cout << a << endl; cout
自增/自减运算
// 自增/自减运算
int b = 0;
<< (b++) << endl;
cout << (++b) << endl;
cout << (b--) << endl;
cout << (--b) << endl;
cout << b << endl; cout
条件运算
// 条件运算
int c = 2;
<< (c > 0? (c -= 1) : (c += 1)) << endl;
cout << c << endl; cout
逗号运算
// 逗号运算
int d = 0, e = 0;
<< (d++, e+2, e--) << endl;
cout << d << ' ' << e << endl; cout
逻辑表达式短路
// 逻辑表达式短路
int f = 0;
<< ((f = 0) and (f = 1)) << endl;
cout << f << endl;
cout << ((f = 1) or (f = 0)) << endl;
cout << f << endl; cout