每当我回完帖时,我都会默默的点一根烟,然后离开
程序代码:
int[] number = new int[100]; Random r = new Random(); //用来生成随机数 int max = 0; int min = 1000; int sum = 0; int doubleNumber = 0; for (int i = 0; i < number.Length; i++) { number[i] = r.Next(1000); //生成1000之内的随机数 max = max > number[i] ? max : number[i]; //得到最大值 min = min < number[i] ? min : number[i]; //得到最小值 sum += number[i]; if (number[i] % 2 == 0) doubleNumber++; Console.Write(number[i] + " "); //输出 } Console.WriteLine("\n最大值是:" + max); ; Console.WriteLine("最小值是:" + min); Console.WriteLine("偶数个数为:" + doubleNumber); Console.WriteLine("平均数是:" + (double)sum / number.Length);
[ 本帖最后由 封闭 于 2010-4-22 13:39 编辑 ]