刚才的是逻辑错误,不好意思,试试下面这个 using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace Test { class Program { static void Main(string[] args) { Console.Write("请输入一个数字:"); int n = Convert.ToInt32(Console.ReadLine()); Random r = new Random(); int[] list = new int[1024*1024]; int count = 0,num; do { bool bsame = false; num = r.Next(10); for(int j=0;j