Untitled

Run Settings
LanguageC#
Language Version
Run Command
using System; namespace ArrayApplication { class MyArray { double getAverage(int[] arr, int size) { int i; double avg; int sum = 0; for (i = 0; i < size; ++i) { sum += arr[i]; } avg = (double)sum / size; return avg; } static void Main(string[] args) { MyArray app = new MyArray(); /* 一个带有 5 个元素的 int 数组 */ int [] balance = new int[]{1000, 2, 3, 17, 50}; double avg; /* 传递数组的指针作为参数 */ avg = app.getAverage(balance, 5 ) ; /* 输出返回值 */ Console.WriteLine( "平均值是: {0} ", avg ); Console.ReadKey(); } } }
Editor Settings
Theme
Key bindings
Full width
Lines