fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace testing
  7. {
  8. class Program
  9. {
  10. public static List<int> RemoveSmallest()
  11. {
  12. int a = 0;
  13. int posa = 0;
  14. int n = 0;
  15. List<int> list = new List<int>();
  16. List<int> numbers = new List<int>();
  17. numbers.Add(5);
  18. numbers.Add(3);
  19. numbers.Add(9);
  20. numbers.Add(-2);
  21. numbers.Add(5);
  22.  
  23. foreach (char f in numbers)
  24. {
  25. if (f < a && n > 0)
  26. {
  27. if (posa == 0)
  28. {
  29. list.Add(a);
  30. a = f;
  31. }
  32. else
  33. {
  34. list.Insert(posa, a);
  35. a = f;
  36. posa = 0;
  37. }
  38. }
  39. else if (a < f && n > 0)
  40. {
  41. list.Add(f);
  42.  
  43. if (posa == 0)
  44. {
  45. posa = n;
  46. }
  47. }
  48. else if (n == 0)
  49. {
  50. a = f;
  51. }
  52. n++;
  53. }
  54. return list;
  55. }
  56.  
  57. static void Main(string[] args)
  58. {
  59. List<int> numbers = new List<int>();
  60. numbers = RemoveSmallest();
  61. Console.WriteLine(numbers);
  62. Console.ReadKey();
  63. }
  64. }
  65. }
Success #stdin #stdout 0.04s 23968KB
stdin
Standard input is empty
stdout
System.Collections.Generic.List`1[System.Int32]