StreamReader file = new StreamReader("input.txt");
int size = Int32.Parse(file.ReadLine());
List<string> list = new List<string>();
while (!file.EndOfStream)
{
list.Add(file.ReadLine());
}
//list.Sort();
List<string> newlist = new List<string>();
for (int i = 0; i < list.Count; i++)
{
if (!newlist.Contains(list[i]))
{
newlist.Add(list[i]);
}
}
newlist.Sort(delegate(string a, string b)
{
if (a.Length < b.Length) return -1;
else if (a.Length > b.Length) return 1;
else return string.Compare(a, b);
});
foreach (string item in newlist)
{
Console.WriteLine(item);
}
int size = Int32.Parse(file.ReadLine());
List<string> list = new List<string>();
while (!file.EndOfStream)
{
list.Add(file.ReadLine());
}
//list.Sort();
List<string> newlist = new List<string>();
for (int i = 0; i < list.Count; i++)
{
if (!newlist.Contains(list[i]))
{
newlist.Add(list[i]);
}
}
newlist.Sort(delegate(string a, string b)
{
if (a.Length < b.Length) return -1;
else if (a.Length > b.Length) return 1;
else return string.Compare(a, b);
});
foreach (string item in newlist)
{
Console.WriteLine(item);
}
반응형
'프로그래밍 > C#' 카테고리의 다른 글
C# 해시테이블 (0) | 2019.03.24 |
---|---|
C# Dictionary 딕셔너리 (0) | 2019.03.24 |
C# 문자열 파싱 parsing split (0) | 2019.03.24 |
C# 문자열 Mid,Left,Right (0) | 2019.03.24 |
C# lock (0) | 2019.03.24 |