从后往前遍历
#include <stdio.h> int main(void) { int n, i, count =0; int arr[50]; int delet; scanf("%d", &n); for(i = 0; i < n; i++) scanf("%d", &arr[i]); scanf("%d", &delet); for(i = n - 1; i >= 0; i--) { if(arr[i] == delet) { for(int m = i + 1; m < n; m++) arr[m - 1] = arr[m]; count++; } } for(i = 0; i < n - count; i++) printf("%d ", arr[i]); return 0; }