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<pair> p = new List<pair>();
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();
}
}
}