using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication68
{
class Program
{
static void Main(string[] args)
{
int[] d = new int[50];
int i = 0;
Random rndNum = new Random();
for ( i = 0; i < d.Length; i++)
{
d[i] = rndNum.Next(0, 100);
}
foreach (int item in d )
{
Console.WriteLine(item+"\t");
if ((i+1)%5==0)
Console.WriteLine();
} Console .Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication68
{
class Program
{
static void Main(string[] args)
{
int[] d = new int[50];
int i = 0;
Random rndNum = new Random();
for ( i = 0; i < d.Length; i++)
{
d[i] = rndNum.Next(0, 100);
}
foreach (int item in d )
{
Console.WriteLine(item+"\t");
if ((i+1)%5==0)
Console.WriteLine();
} Console .Read();
}
}
}
这段代码使用C#创建了一个包含50个0到100之间随机数的数组。每个数打印后接一个制表符,并在每行打印5个数后换行。程序通过`Random`类生成随机数,使用`foreach`循环遍历并输出数组。
9657

被折叠的 条评论
为什么被折叠?



