嗨,我正在尝试在我的随机数生成中添加随机数的总和,以获得生成的随机数的平均值,并将它们显示在消息框中。我不能做数组。这是我到目前为止所拥有的:
class Program
{
static double average = 0;
static double sum = 0;
static void Main(string[] args)
{
Random number = new Random();
int min = int.MaxValue, max = int.MinValue;
string result = "\tn \n";
for (int counter = 0; counter < 100; counter++)
{
int n = number.Next(0, 1000);
// Console.WriteLine(n);
if (n < min)
min = n;
if (n > max)
max = n;
}
sum = sum + (number.Next()) ;
average = sum / 100;
int range = min - (min + 1);
result += " \t"
+ min
+ " \t"
+ max
+ " \t"
+ average
+ " \t"
+ sum
+ " \t"
+ range;
MessageBox.Show(result, "Min = {0}, Max = {1}, Range = {2}");
}
我想要一个提示来解决这个问题,而不是刚刚给我的代码列表。谢谢你。