【发布时间】:2013-10-20 09:35:12
【问题描述】:
这个程序对于 C# 程序员来说可能看起来很简单,但是,我是 C# 编程的新手。到目前为止,我已经编写了一半的程序,但是我不确定如何完成其余的步骤。这是我编写的程序和说明。谢谢
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Arrays
{
class Program
{
static void Main(string[] args)
{
int[] array;
Random randomNumbers = new Random();
for( int i = 0; i < array.Length; i++)
{
NumInput[randomValue];
int randomValue = randomNumbers.Next(0, 500);
}
for( int i = 0; i < array.Length; i++)
{
Console.WriteLine("The array value is: ", NumInput[i]);
}
}
}
}
说明:
开发一个实现 int 数组的 C# 控制台应用程序。使用 2 个“for”循环,第一个使用 Random 类填充数组,使用 Random 类的 next 方法生成随机整数,第二个 for 循环遍历填充的数组并打印由随机数发生器。使用数组的长度变量来保持两个循环的数组边界。
可能的输出可能如下所示:
数组值为488
数组值为402
数组值为237
数组值为48
数组值为390
数组值为186
数组值为425
数组值为342
数组值为477
数组值为319
按任意键继续。 . .
【问题讨论】:
-
您可以先定义一个名为
int的数组array... -
好的,正确的写法是 int[] 数组;对吗?
-
并且指令说:制作两个(即2个)for循环。目前你有一个。请注意,软件开发人员最欠发达的技能之一就是阅读......
-
伙计们,你们都是什么批评家,大家都忘了他们在哪里说的吗?
-
@user2888973 “这是我编写的程序”更有可能是“这是我为完成作业而获得的代码”