public static void Main (string[] args)
{
Random ran=new Random();
int[] array = new int[100];
ArrayList List = new ArrayList ();
while (List.Count < 100) {
int num = ran.Next (1, 101);
if (!List.Contains (num))
List.Add (num);
}
for (int i = 0; i < 100; i++)
{
// Random ran=new Random();
array [i] = (int)List [i];
Console.WriteLine ("第{0}个数为:{1}",i,array [i]);
{
Random ran=new Random();
int[] array = new int[100];
ArrayList List = new ArrayList ();
while (List.Count < 100) {
int num = ran.Next (1, 101);
if (!List.Contains (num))
List.Add (num);
}
for (int i = 0; i < 100; i++)
{
// Random ran=new Random();
array [i] = (int)List [i];
Console.WriteLine ("第{0}个数为:{1}",i,array [i]);
}
}
运行结果如下: