小编Vam*_*han的帖子

为什么 std::set_intersection 不起作用?

我有以下代码:

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

typedef long long ll;

int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
    string a;
    string b;
    cin>>a;
    cin>>b;
    vector<char> v1(a.begin(),a.end());
    vector<char> v2(b.begin(),b.end());

    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    vector<char> c;
    auto ls = set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),c.begin());
    cout<<"hello"<<endl;
    cout<<ls-c.begin()<<endl;
    cout<<c.size()<<endl;

}
return 0;
}
Run Code Online (Sandbox Code Playgroud)

在 set_intersection 线之后没有打印任何内容,甚至没有与相交线无关的“hello”,为什么?

c++ stl set-intersection

0
推荐指数
1
解决办法
164
查看次数

标签 统计

c++ ×1

set-intersection ×1

stl ×1