//下面是整个完整代码
using System;
using System.Collections.Generic;
using System.Text;

namespace ArrayMaxValue74
{
    class Program
    {
        public static int maxValue(int[] s)
        {
            int temp = s[0];
            for (int i = 0; i < s.Length; i++)
            {
                if (temp<=s[i])
                {
                    temp = s[i];
                }
            }
            return temp;
        }
        static void Main(string[] args)
        {
            int[] s={10,4,5,7,8,1};
            Console.WriteLine("the Max Value : {0}",maxValue(s));
            Console.ReadKey();
        }
    }
} 

 

 

用Linq直接查询int[] s = { 1, 5, 8, 9, 3 };

int xxx = (from mm in s select mm).Max();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2021-08-18
  • 2021-09-29
猜你喜欢
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案