当前位置: > 怎样随机数生成一数组,长度为10,随机数为1~100的奇数,求最大值最小值,C#语言...
题目
怎样随机数生成一数组,长度为10,随机数为1~100的奇数,求最大值最小值,C#语言

提问时间:2021-02-23

答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RandomArray
{
class Program
{
static void Main(string[] args)
{
int[] myRanArray = new int[10];
Random Ran = new Random();
for (int j = 0; j < 10; j++)
{
myRanArray[j] = 2 * Ran.Next(1,50) - 1;
}
Console.WriteLine("the Random Array is:");
int i=0;
int max = 0;
while (i < 10)
{
if (myRanArray[i] > max)
{
max = myRanArray[i];
}
Console.Write("{0} ",myRanArray[i]);
i++;
}
Console.WriteLine(" The max number of the array is:{0}",max);
Console.ReadKey();
}
}
}
我是初学者,见笑了.
举一反三
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
1,人们染上烟瘾,最终因吸烟使自己丧命.
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.