static void Main(string[] args)
{
//Test("张三",98,97,98,66,55);
Console.WriteLine("请输入一组数字");
string str = Console.ReadLine();
string[] strLst = str.Split(',');
int[] nums = Array.ConvertAll(strLst, int.Parse);
int max;
int H= GetSum(out max,nums);
Console.WriteLine("最大值是{0},总和是{1}", max, H);
Console.ReadKey();
}
public static void Test(string name,params int[] score) //params只能放在形参类别中的最后一个元素
{
int sum = 0;
for (int i = 0; i < score.Length; i++)
{
sum += score[i];
}
Console.WriteLine("{0}这次考试的总成绩是{1}分",name,sum);
}
/// <summary>
/// 任意数组的和,最大值
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static int GetSum(out int max, params int[] s)
{
max = s[0];//最大值
int sum = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] > max)
{
max = s[i];
}
sum +=s[i];
}
return sum;
}