一码屏穿

导航

半夜睡不着--Typoglycemia

晚上看到老赵出题,一时手痒,随便写写,欢迎拍砖。

关于http://en.wikipedia.org/wiki/Typoglycemia 

我的涂鸦~

        static void Main(string[] args)
        {
            const string sampleText = "According to a reserch at Cambridge University";
            //var a = new A();
            var sb = new StringBuilder();
            var strs = sampleText.Split(' ');
            foreach (var str in strs)
            {
                sb.Append(MakeRandom(str));
                sb.Append(" ");
            }

            Console.WriteLine(sb.ToString().TrimEnd());
            Console.ReadLine();
        }

        static public string MakeRandom(string content)
        {
            var rnd = new Random();
            var sb = new StringBuilder(content);
            
            for (var idx = 1; idx < sb.Length - 1; idx++)
            {
                var temp = sb[idx];
                sb.Remove(idx, 1);
                sb.Insert(rnd.Next(1, sb.Length - 1), temp);
            }

            return sb.ToString();
        }    

欢迎指教!

posted on 2012-11-06 01:45  一码屏穿  阅读(568)  评论(1编辑  收藏  举报