系统输出随机数求和与平均数!与大家共享!
using System; using System.Collections; class count { static void Main() { Console.WriteLine("P INPUT NUM YOU WANT:"); int a=int.Parse(Console.ReadLine()); int[] all=new int[a]; decimal sum=0; int b=0;
Random r=new Random(); ArrayList aa=new ArrayList(); for(decimal i=0;i<a;i++) { b=r.Next(0,100); Console.WriteLine(b+","); aa.Add(b); sum+=b; } Console.WriteLine("数组的和:"+sum); Console.WriteLine("平均数:"+sum/a); System.Threading.Thread.Sleep(10000); }
}