[조영준]의 하위 문서입니다. = 개요 = * 언어 : C# * 느낀 점 * List를 까먹고 배열을 썼다가 피를 봤었습니다. * Compare은 인터페이스를 구현시킨건가? 음... * C#은 이런 저런 일을 하는데 편안한 기능이 많다보니 다른 언어로 짠 다른 분들의 코드를 보니 게을러지는 느낌이 살짝. = 소스 = == r1(13/05/06) == {{{ using System; using System.IO; using System.Collections.Generic; namespace CodeRace { class Program { public struct pair { public string word; public int count; } public static int Compare(pair x, pair y) { return x.word.CompareTo(y.word); } static void Main(string[] args) { List p = new List(); pair temp; string[] s; string line; StreamReader sr = new StreamReader(@"C:\test.txt"); while ((line = sr.ReadLine()) != null) { s = line.Split(' '); for (int i = 0; i < s.Length; i++) { for (int j = 0; j < p.Count+1; j++) { if (j == p.Count) { temp.word = s[i]; temp.count = 1; p.Add(temp); break; } if (p[j].word == s[i]) { temp.word = p[j].word; temp.count = p[j].count + 1; p[j] = temp; break; } } } } p.Sort(Compare); for (int i = 0; i < p.Count; i++) { if (p[i].word == null) break; Console.Write(p[i].word+" "+p[i].count+"\n"); } Console.Read(); } } } }}} == r0(13/05/06) == [정모/2013.5.6/CodeRace#s-2.2]