编写c#控制台应用程序,在其中定义方法calculate
发布网友
发布时间:2022-07-01 19:05
我来回答
共1个回答
热心网友
时间:2023-05-03 23:27
方法如下:
public static void calculate(double[] intputData, out double Sum, out double proct)
{
Sum = 0;
proct = 1;
for (int i = 0; i < intputData.Length; i++)
{
Sum = Sum + intputData[i];
proct = proct * intputData[i];
}
}
调用方法:
static void Main(string[] args)
{
double Sum, proct;
calculate(new double[] { 1, 2, 3, 4 }, out Sum, out proct);
Console.WriteLine("Sum:"+Sum);
Console.WriteLine("proct:" + proct);
Console.Read();
}