Skip to content

Instantly share code, notes, and snippets.

@sangwon090
Last active December 31, 2020 04:34
Show Gist options
  • Save sangwon090/1ee75c7cd3853b0b15326601c5b0d507 to your computer and use it in GitHub Desktop.
Save sangwon090/1ee75c7cd3853b0b15326601c5b0d507 to your computer and use it in GitHub Desktop.
[C#] 중복 문장 제거
// NeverLanCTF 에서 사용하기 위해 작성함.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace CSharp_Playground
{
class Program
{
static void Main(string[] args)
{
string[] input = File.ReadAllLines("canyoufindme.txt");
List<string> data = new List<string>();
foreach(string str in input)
{
if (!data.Contains(str)) data.Add(str);
}
Console.WriteLine($"전체 문장 : { input.Length }\n중복된 문장 : { input.Length - data.Count }\n남은 문장 : { data.Count }");
File.WriteAllLines("canyoufindme-out.txt", data.ToArray());
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment