看名字测缘分、名字测身价

1.看名字测缘分

//测缘分
            Console.WriteLine("请输入姓名1:");
            string name1 = Console.ReadLine();
           
            Console.WriteLine("请输入姓名2:");
            string name2 = Console.ReadLine();

            int seed1 = 0;
            int seed2 = 0;
            if (name1.Length == 2)
            {
                seed1 = (int)Convert.ToChar(name1.Substring(0, 1)) + (int)Convert.ToChar(name1.Substring(1, 1));
            }
            else
            {
                seed1 = (int)Convert.ToChar(name1.Substring(0, 1)) + (int)Convert.ToChar(name1.Substring(1, 1)) + (int)Convert.ToChar(name1.Substring(2, 1));

            }
            Random a = new Random(seed1);
            int nan = a.Next(10);
            //Console.WriteLine(nan);

            if (name2.Length == 2)
            {
                seed2 = (int)Convert.ToChar(name2.Substring(0, 1)) + (int)Convert.ToChar(name2.Substring(1, 1));
            }
            else
            {
                seed2 = (int)Convert.ToChar(name2.Substring(0, 1)) + (int)Convert.ToChar(name2.Substring(1, 1)) + (int)Convert.ToChar(name2.Substring(2, 1));

            }
            Random b = new Random(seed2);
            int nv = b.Next(10);
            //Console.WriteLine(nv);

            int aaa = Math.Abs(nan-nv);
            //Console.WriteLine(aaa);

            if (aaa < 5 && aaa >= 0)
            {

                Console.WriteLine("你俩青梅竹马");

            }
            else
            {
                Console.WriteLine("您俩差距太大了");

            }

2.名字测身价

 Console.WriteLine("请输入你的姓名:");
                string name = Console.ReadLine();

                int seed = 0;
                if (name.Length == 2)
                {
                    seed = (int)Convert.ToChar(name.Substring(0, 1)) + (int)Convert.ToChar(name.Substring(1, 1));
                    //(int)Convert.ToChar(name.Substring(0, 1)从name中截取一个字符串,先转成一个字符,再转成整数
                }
                else
                {
                    seed = (int)Convert.ToChar(name.Substring(0, 1)) + (int)Convert.ToChar(name.Substring(1, 1)) + (int)Convert.ToChar(name.Substring(2, 1));
                }

                Random rand = new Random(seed);
                int sj = 500000 + rand.Next(5000000);

                Console.WriteLine("你的身价为:" + sj);
            }

 

posted @ 2015-07-09 22:06  Franky2015  阅读(1573)  评论(0编辑  收藏  举报