int[] num = new int[10];Random r = new Random(); for(int i=0;i<num.Length;i++) { num[i] = r.Next(1,11); Console.Write(num[i] + " "); }Console.WriteLine("从大到小排列是:"); int t=0; for (int i=0;i<num.Length;i++) { for(int j=i+1;j<num.Length;j++) { if (num[i] < num[j]) { t = num[i]; num[i] = num[j]; num[j] = t; } } Console.Write(num[i] + " "); }
添加回答
举报
0/150
提交
取消