0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

C++ 競プロ 学習記録#3

Last updated at Posted at 2023-10-09

集合

  • 重複無しの配列の問題
    重複する要素のない、「集合」を用いた。
    重複のない配列、string型の順序付き配列、計算量を考えるときに用いる。
    #include <set>
    set<型> s;

  • for文で全要素の参照
    for(auto it = s.begin(); it != s.end(); it++) {
    cout << *it;
    }
    または
    for(auto x : s) {
    cout << x << endl;
    }

  • 要素追加
    s.insert(要素);

  • 要素削除
    s.erase(要素);

参考

C++のstd::setの使い方について詳しく解説

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?