小编Har*_*war的帖子

字符和字符串的字符串连接

#include <bits/stdc++.h>
using namespace std;

int main() 
{
    string s1 = "Alice";
    s1 +='\0';
    s1 +='\0';
    cout << s1.size() << endl;         // output: 7

    string s2 = "Alice";
    s2 += "\0";
    s2 += "\0";
    cout << s2.size() << endl;         // output: 5
}
Run Code Online (Sandbox Code Playgroud)

这里有什么问题?

请解释单引号和双引号在连接中的作用的区别。

c++

3
推荐指数
1
解决办法
81
查看次数

C++ 中 Vector 的 std::upper_bound 和 std::lower_bound 的复杂度是多少?

std::lower_bound和函数的复杂度是多少std::upper_bound

我知道万一std::set<int>是这样log(n),但我不知道std::vector<int>

我正在使用向量 和 来实现最长递增子序列std::lower_bound

这段代码的复杂度是多少?

int LIS2(vector<int> a) {
    vector<int> v;
    for (int i = 0; i < a.size(); i++) {
        auto it = lower_bound(v.begin(), v.end(), a[i]);
        if (it != v.end()) 
            *it = a[i];
        else 
            v.push_back(a[i]);
    }
    return v.size();
}
Run Code Online (Sandbox Code Playgroud)

c++ stdvector lower-bound upperbound lis

-3
推荐指数
1
解决办法
3251
查看次数

标签 统计

c++ ×2

lis ×1

lower-bound ×1

stdvector ×1

upperbound ×1