C++ 벡터 차집합

Jmnote (토론 | 기여)님의 2023년 12월 26일 (화) 01:07 판 (새 문서: ==개요== ;C++ 벡터 차집합 <syntaxhighlight lang='cpp' run> #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector<string> v1...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

C++ 벡터 차집합
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<string> v1 = {"A","B","C","D"};
    vector<string> v2 = {"C","D","E","F"};
    
    vector<string> v(v1.size()+v2.size());
    set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), v.begin());
    for(const auto& el: v) cout << el << ' '; // A B 
}


2 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}