fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8.  
  9. int[] myArray = {1,3,4,7,9,12,17,20,30,35};
  10. Console.Write("请输入要插入的值:");
  11. int f = int.Parse(Console.ReadLine());
  12. myArray = myArray.Where(x => x < f).Concat(new int[] { f }).Concat(myArray.Where(x => x >= f)).ToArray();
  13. Console.WriteLine("显示插入后的数组:");
  14. foreach (int x in myArray)
  15. Console.Write(x + " ");
  16.  
  17. }
  18.  
  19. }
Success #stdin #stdout 0.05s 24000KB
stdin
100
stdout
请输入要插入的值:显示插入后的数组:
1 3 4 7 9 12 17 20 30 35 100