本文介绍了如何创建大小为7的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建7号数组来存储一周的产品价格并计算平均价格?
How to create an array of size 7 which stores product price for a week and calculate average price?
推荐答案
double [] prices = new double[7];
有一个非常整洁的网站可以找到以下问题的答案:此处 [ ^ ]
There is a very neat site to find answers to these questions: Here[^]
void Main()
{
decimal[] ProductPrice ={10,20,30,40,50,60,70};
[edit]Average method can be used[/edit]
// decimal avgPrice = ProductPrice.Sum() / ProductPrice.Length;
avgPrice = ProductPrice.Average();
Console.WriteLine ("The average of prices = {0}",avgPrice);
}
这篇关于如何创建大小为7的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!