using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Random rd = new Random();
int n = 10;
int min = 9, max = 100;
List<int> list1= new List<int>(n);
for(int i=0;i<=n;)
{
int currentn = rd.Next(min,max);
if (!list1.Contains(currentn))
{
list1.Add(currentn);
++i;
}
}
//descsort(ref list1); //降序排列自定义方法
list1.Sort();
list1.Reverse();
Console.Write("/n");
for (int i = 0; i <= n; i++)
Console.Write(list1[i] + " ");
Console.ReadKey();
}
static List<int> descsort(ref List<int> paralist)
{
for (int i = 0; i <= paralist.Count-1; i++)
{
for (int j = i; j <= paralist.Count-1; j++)
{
if (paralist[i] < paralist[j])
{
int temp = paralist[i];
paralist[i] = paralist[j];
paralist[j] = temp;
}
}
}
return paralist;
}
}
}