zoukankan      html  css  js  c++  java
  • 基本算法

        class Program
        {
            static void Main()
            {
                #region
                //HashSet<int> myList = new HashSet<int>();
    
                //while (myList.Count < 100)
    
                //{
    
                //    int num = new Random().Next(1, 101);
    
                //    myList.Add(num);
    
                //}
    
                //foreach (int item in myList)
    
                //{
    
                //    Console.WriteLine(item);
    
                //}
    
                //Console.WriteLine(myList.Count);
    
                //Console.ReadLine();
    
                #endregion
    
                #region 随机数插入
    
    
                //HashSet<int> vs = new HashSet<int>();
                //while (vs.Count < 100)
                //{
                //    vs.Add(new Random().Next(1, 101));
                //}
                //foreach (var item in vs)
                //{
                //    Console.WriteLine(item);
                //}
                //Console.WriteLine(vs.Count);
                //Console.ReadLine();
                #endregion
    
                #region 1-2+3-4
    
                //int sum = 0;
    
                //for (int i = 1; i <= 11; i++)
                //{
    
                //    if (i % 2 == 0)
                //    {
                //        sum -= i;
                //    }
                //    else
                //    {
                //        sum += i;
                //    }
                //}
                //Console.WriteLine(sum);
                //Console.ReadLine();
    
                #endregion
    
                #region 1,1,2,3,5,8,13...递归
    
                //Console.WriteLine(Jaia(20));
                //Console.ReadLine();
                #endregion
    
                #region
                //new B();
                //Console.WriteLine();
                #endregion
    
                #region 冒泡
                //MaoPao();
                #endregion
    
                #region 反射程序集
                //Assembly asm = Assembly.LoadFrom(@"C:WindowsMicrosoft.NETFrameworkv2.0.50727System.Web.dll");
                //var a= asm.GetTypes();
                //foreach (var item in a)
                //{
                //    Console.WriteLine(item);
    
                //}
                #endregion
    
                #region 反射基本信息
                //int a = 0;
                //TypeExplore(a.GetType());
                #endregion
    
                #region 反射基本类型
                //int b = 2;
                //Type type = b.GetType();
                //MemberExplore(b.GetType());
                #endregion
    
                #region 无参数构造函数创建参数
                //使用CreateInstance创建对象
                Assembly asm = Assembly.GetExecutingAssembly();
                object obj = asm.CreateInstance("ConsoleApp12.Calculator", true);
    
                //使用Activator.CreateInstance
                ObjectHandle handler = Activator.CreateInstance(null, "ConsoleApp12.Calculator");
                Object objj = handler.Unwrap();
                #endregion
    
            }
            private static int Jaia(int a)
            {
                if (a <= 0)
                    return 0;
                else if (a == 1 || a == 2)
                    return 1;
                else
                {
                    return Jaia(a - 1) + Jaia(a - 2);
                }
    
            }
            /// <summary>
            /// 冒泡
            /// </summary>
            public static void MaoPao()
            {
                int[] array = { 1, 3, 5, 7, 90, 2, 4, 6, 8, 10 };
                int temp = 0;
                for (int i = 0; i < array.Length - 1; i++)
                {
                    for (int j = i + 1; j < array.Length; j++)
                    {
                        if (array[j] < array[i])
                        {
                            temp = array[i];
                            array[i] = array[j];
                            array[j] = temp;
                        }
                    }
                }
            }
    
            /// <summary>
            /// 反射基本信息
            /// </summary>
            /// <param name="t"></param>
            public static void TypeExplore(Type t)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("名称信息:
    ");
                sb.Append("Name:" + t.Name + "
    ");
                sb.Append("基类型:" + t.BaseType + "
    ");
                Console.WriteLine(sb);
            }
    
            public static void MemberExplore(Type t)
            {
                StringBuilder sb = new StringBuilder();
                MemberInfo[] memberInfos = t.GetMembers();
                sb.Append("查看类型" + t.Name + "的成员信息;
    ");
                foreach (MemberInfo  mi in memberInfos)
                {
                    sb.Append("成员" + mi.ToString().PadRight(40) + "类型:" + mi.MemberType + "
    ");
                }
                Console.WriteLine(sb.ToString());
            }
        }
  • 相关阅读:
    树莓派系统Raspbian安装小结
    树莓派安装centos 7系统
    Ubuntu下安装SSH服务
    使用xUnit为.net core程序进行单元测试(4)
    使用xUnit为.net core程序进行单元测试(3)
    使用xUnit为.net core程序进行单元测试 -- Assert
    使用xUnit为.net core程序进行单元测试(1)
    用 Identity Server 4 (JWKS 端点和 RS256 算法) 来保护 Python web api
    asp.net core 2.0 查缺补漏
    "软件随想录" 读书笔记
  • 原文地址:https://www.cnblogs.com/HuangLiming/p/14028279.html
Copyright © 2011-2022 走看看