zoukankan      html  css  js  c++  java
  • c#委托之最大

      public delegate int ceshi(object o1, object o2);
            static void Main(string[] args)
            {
                string[] a = { "abCdeg", "ssxAf" };
                object [] b = { 2, 9, 5, 6 };
                object result=zhenga(a,gets);
                Console.WriteLine(result);
               
                
              
                Console.ReadKey();
            }
            public static int compare(object o1, object o2) 
            {
                int num1 = (int)o1;
                int num2 = (int)o2;
                return num1 - num2;
            }
    
            public static int gets(object o1, object o2) 
            {
                string num1 = (string)o1;
                string num2 = (string)o2;
                return num1.Length - num2.Length;
            }
            public static object zheng(object[] name,ceshi aaax)
            {
    
                object max = name[0];
                for (int i = 0; i < name.Length; i++)
                {
                    //max-name[i]<0
                    if (aaax(max,name[i])<0)
                    {
                        max = name[i];
                    }
                }
                return max;
            }
            public static object zhenga(object[] name, ceshi ce)
            {
                object names = name[0];
                for (int i = 0; i < name.Length; i++)
                {
                    if (ce(name[i],names)>0)
                    {
                        names = name[i];
                    }
    
                }
                return names;
    
    
            }
    

      

  • 相关阅读:
    第十二周作业
    第十一周作业
    第十一次上机作业
    第十次上机作业
    第九周上机作业
    第八周作业
    第八次上机练习
    第七周作业
    第八周
    第六周作业
  • 原文地址:https://www.cnblogs.com/mengluo/p/5522256.html
Copyright © 2011-2022 走看看