1 int[] ints1 = new int[] { 2, 5, 6, 10, 15, 19 };
 2             int[] ints2 = new int[] { 3, 7, 11, 18 };
 3             ArrayList lists = new ArrayList();
 4             ArrayList temp = new ArrayList();
 5             lists.AddRange(ints1);
 6             temp.AddRange(ints2);
 7             for (int i = 0; i < lists.Count; i++)
 8             {
 9                 if (temp.Count > 0)
10                 {
11                     var strs2First = temp[0];//取第一个元素
12                     if (Int32.Parse(lists[i].ToString()) >= Int32.Parse(strs2First.ToString()))
13                     {
14                         lists.Insert(i, strs2First);
15                         temp.RemoveAt(0);
16                     }
17                     else if (Int32.Parse(lists[lists.Count - 1].ToString()) < Int32.Parse(strs2First.ToString()))
18                     {
19                         lists.Insert(lists.Count, strs2First);
20                         temp.RemoveAt(0);
21                     }                    
22                 }                
23             }

 

相关文章:

  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-09-20
相关资源
相似解决方案