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?

paiza.ioでc# その11

Posted at

概要

paiza.ioでc#、やってみた。
練習問題やってみた。

練習問題

hashsetを使え。

サンプルコード

using System;
using System.Collections.Generic;

internal class Program {
    static void Main(string[] args) {
        //HashSet
        var hst1 = new HashSet<int>() { 4, 1, 3, 8 };
        var hst2 = new HashSet<int>() { 3, 5, 2, 4 };
        hst2.ExceptWith(hst1);
        Console.WriteLine("hst1とhst2の差集合:[{0}]", string.Join(" ", hst2));
        //SortedSet
        var sst1 = new SortedSet<int>() { 4, 1, 3, 8 };
        var sst2 = new SortedSet<int>() { 3, 5, 2, 4 }; 
        sst2.ExceptWith(sst1);
        Console.WriteLine("sst1とsst2の差集合:[{0}]", string.Join(" ", sst2));
    }
}



実行結果

hst1とhst2の差集合:[5 2]
sst1とsst2の差集合:[2 5]

成果物

以上

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?