Playground

在这里尽情试验你的代码!

初始化代码区

Caution

初始化代码区域主要用于引入头文件,此代码区域不可编辑。

#include <iostream>
using namespace std;

cout.setf(ios::boolalpha);
cout << "初始化完成!" << endl;

试验代码区

Note

点击页面右上角Active按钮,等待按钮下方状态信息显示

Status:Kernel Connected kernel thebe.ipynb status changed to ready[idle]

即可编辑试验代码区的代码。编辑完成后请点击run all钮执行代码。

显式类型转换

double d = 3.14;
int i = static_cast<int>(d); // cast double to int
int j = (int)'A'; // cast char to int

隐式类型转换

double pi = 3.14;
int p = pi / 2; // cast int to double, then double back to int
bool b = p;     // cast int to bool

有符号与无符号整数类型转换

unsigned int u = 0xFFFFFFFF;
int s = (int)u;
cout << "unsigned: " << u << ", int: " << s << '\n';