题目
怎样随机数生成一数组,长度为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();
}
}
}
我是初学者,见笑了.
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,人们染上烟瘾,最终因吸烟使自己丧命.
最新试题
- 1brusing encounter什么意思
- 2would you like another banana for your friend?would you like ______ ______ banana for your friend?
- 3如果式子2x²+3x+7的值为8,那么式子4x²+6x-9的值等于____.
- 4穷图匕见的主人公是谁
- 5哈尔滨降水季节变化特点是 乌兰巴托降水季节变化特点是 造成两地降水差异的主要原因是.
- 6孙权劝学的意思
- 7三角形三边长分别为4、1-2a、7,则a的取值范围.
- 8某牛奶加工厂现有鲜奶9吨,若在市场上直接销售,每吨可获利500元;制成酸奶销售,每吨可获利1200元;制成奶片销售,每吨可获利2000元,该工厂的生产能力是:如果制成酸奶,每天可加工3吨,制成奶片可加
- 9路面平坦,几乎与河面平行中几乎的意思
- 10过抛物线y2=4x的顶点O作两条互相垂直的直线分别交于AB两点,则线段AB的中点P的轨迹方程是拜托各位大神
热门考点