static void RemoveDataFromList(int[] nums, int val) { int j = nums.Length - 1; int i = 0; while (i <= j) // 感觉总卡在边界上 { if (nums[i] == val) { int temp = nums[j]; nums[j] = nums[i]; nums[i] = temp; j--; } else { i++; } } int rs = j + 1; Console.WriteLine($"新数组的长度:{rs}"); }
标签:val,nums,int,void,元素,移除 From: https://www.cnblogs.com/Insist-Y/p/17352071.html