跳到文档正文
语言支持 / C++
12 / 18
当前对 C++ 的支持仍有限,正在持续完善。本文档说明现阶段的支持范围和限制。 请在使用时注意以下规则,避免使用不兼容的语法特性。
支持以下基础类型的声明和使用:
char, string, bool, int, float, double
示例:
支持以下容器及其嵌套形式:
| 容器类型 | 示例 |
|---|---|
vector<T> | vector<int> nums3 |
vector<vector<T>> | 二维动态数组 |
map<T1, T2> | map<int, string> |
unordered_map<T1,T2> | 哈希表 |
queue<T> | 队列 |
set<T> | 集合 |
unordered_set<T> | 集合 |
stack<T> | 栈 |
约束条件:
map/unordered_map 的 Key 必须为基础类型(char/string/bool/int/float/double)vector<vector<int>>)可直接使用以下预定义结构:
int 为返回值的 main 函数, 并显式返回 int[&]{})<vector>, <algorithm> 等),无需手动引入
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>
| 类别 | 示例 | 备注 |
|---|---|---|
| 头文件引入 | #include <sstream> | 已内置常用库 |
| 静态方法 | MyClass::staticFunc() | 不支持类静态方法 |
匿名函数(无 &) | [](\){ ... } | 必须写成 [&](\){ ... } |
stringstream | ss << "text" | 改用 to_string 等替代方案 |
| 函数内结构体 | void func() { struct X } | 结构体需在全局或类内定义 |
| 调用自定义函数时传递未显式声明的参数 | bubbleSort({5, 2, 9, 1, 9, 9, 1, 2, 5.6, 0, 3}); | 应写成bubbleSort(std::vector<double>{5, 2, 9, 1, 9, 9, 1, 2, 5.6, 0, 3});或者 std::vector<double> arr{5, 2, 9, 1, 9, 9, 1, 2, 5.6, 0, 3};bubbleSort(arr); |
请根据上述规则调整代码,如有问题请联系平台支持。