[ACM]Q10282: Babelfish

[ACM]Q10282: Babelfish


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Q10282
{
    class Program
    {
        static private Dictionary<string, string> dct = new Dictionary<string, string>();
        static private string[] sarr; static private char[] par = { ' ' };
        static private string str;
        static void Main(string[] args)
        {
            for (; ; )
            {
                for (; ; )
                {
                label: Console.Write("input>>>");
                    sarr = Console.ReadLine().Split(par, StringSplitOptions.RemoveEmptyEntries);
                    if (sarr.Length == 0) break;
                    else if (sarr.Length != 2) goto label;
                    dct.Add(sarr[1], sarr[0]);
                }
                for (; ; )
                {
                    Console.Write("translate>>>");
                    str = Console.ReadLine();
                    if (dct.ContainsKey(str))
                    {
                        string result;
                        dct.TryGetValue(str, out result);
                        Console.WriteLine(result);
                    }
                    else
                    {
                        Console.WriteLine("eh");
                    }
                    if (str == "") break;
                }
            }
        }
    }
}