当前位置: 首页>>代码示例>>C++>>正文


C++ Array1D::pop_back方法代码示例

本文整理汇总了C++中Array1D::pop_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1D::pop_back方法的具体用法?C++ Array1D::pop_back怎么用?C++ Array1D::pop_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Array1D的用法示例。


在下文中一共展示了Array1D::pop_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static void CombinationWithDuplicatedElementsVer2Helper(Array1D &array, int left,
                                                        int k, int times,
                                                        Array1D &temp,
                                                        Array2D &result)
{
    if (array.size() - left < k) { return; }
    if (k == 0) {
        result.push_back(temp);
        return;
    }
    for (int i = left; i <= array.size(); i++) {
        if (i == 0 || array[i] != array[i - 1]) {
            times = 1;
            temp.push_back(array[i]);
            CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, 1, temp, result);
            temp.pop_back();
        }
        else {
            times++;
            if (temp.size() >= times - 1 && temp[temp.size() - times + 1] == array[i]) {
                temp.push_back(array[i]);
                CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, times, temp, result);
                temp.pop_back();
            }
        }
    }
}
开发者ID:xiejianhe,项目名称:FindWork,代码行数:27,代码来源:combination.cpp

示例2: CombinationWithDuplicatedElementsHelper

static void CombinationWithDuplicatedElementsHelper(Array1D &array, int left, int k,
                                                    int times, Array1D &temp, Array2D &result)
{
    assert(left >= 0);

    if (array.size() - left < k) { return; }
    if (k == 0) {
        result.push_back(temp);
        return;
    }
    if (left == 0 || array[left] != array[left - 1]) {
        temp.push_back(array[left]);
        CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, 1, temp, result);
        temp.pop_back();
        CombinationWithDuplicatedElementsHelper(array, left + 1, k, 1, temp, result);
    }
    else {
        if (temp.size() >= times && temp[temp.size() - times] == array[left]) {
            temp.push_back(array[left]);
            CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, times + 1, temp, result);
            temp.pop_back();
        }
        CombinationWithDuplicatedElementsHelper(array, left + 1, k, times + 1, temp, result);
    }
}
开发者ID:xiejianhe,项目名称:FindWork,代码行数:25,代码来源:combination.cpp

示例3: CombinationHelper

static void CombinationHelper(Array1D &array, int left, int right, int k,
                              Array1D &temp, Array2D &result)
{
    assert(!array.empty());
    assert(left >= 0 && right >= 0);

    if (right - left + 1 < k) { return; }
    if (k == 0) {
        result.push_back(temp);
        return;
    }
    temp.push_back(array[left]);
    CombinationHelper(array, left + 1, right, k - 1, temp, result);
    temp.pop_back();
    CombinationHelper(array, left + 1, right, k, temp, result);
}
开发者ID:xiejianhe,项目名称:FindWork,代码行数:16,代码来源:combination.cpp

示例4: assert

static void CombinationVer2Helper(Array1D &array, int left, int right, int k,
                                  Array1D &temp, Array2D &result)
{
    assert(!array.empty());
    assert(left >= 0 && right >= 0);

    if (k == 0) {
        result.push_back(temp);
        return;
    }

    for (int i = left; i <= right - k + 1; i++) {
        temp.push_back(array[i]);
        CombinationVer2Helper(array, i + 1, right, k - 1, temp, result);
        temp.pop_back();
    }
}
开发者ID:xiejianhe,项目名称:FindWork,代码行数:17,代码来源:combination.cpp


注:本文中的Array1D::pop_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。