//直接上代码:
1 /// <summary> 2 /// 实现正负数重新排序 3 /// </summary> 4 /// <param name="arr"></param> 5 public static void ZhengfuSort(int[] arr) 6 { 7 List<int> list = new List<int>(); 8 foreach(var item in arr) 9 { 10 if(item<0) 11 { 12 list.Add(item); 13 } 14 } 15 foreach (var item in arr) 16 { 17 if (item > 0) 18 { 19 list.Add(item); 20 } 21 } 22 foreach (var item in list) 23 { 24 Console.WriteLine(item+","); 25 } 26 Console.ReadKey(); 27 }