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


    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);
                }
  • 相关阅读:
    在Linux中运行Nancy应用程序
    医疗行业信息化学习资源
    Windows Live Writer 的昨日荣光
    读书笔记:李叔同,说佛(上),为人十训
    使用Expression Tree构建动态LINQ查询
    读书笔记:季羡林关于如何做研究学问的心得
    XML序列化的时候如何支持Namespace
    Kafka Consumer
    Linux环境安装Golang
    Linux 下 zip 文件解压乱码如何解决
  • 原文地址:https://www.cnblogs.com/franky2015/p/4634382.html
Copyright © 2020-2023  润新知