#include <stdio.h> #include<stdlib.h> int main() { int N; scanf("%d", &N); //动态内存分配 int* arr = (int*)malloc(N * sizeof(int)); int* a = (int*)malloc(N * sizeof(int)); if (a == NULL || arr == NULL)//printf("内存分配失败\n"); { free(a); free(arr); return 1; } int i; for (i = 0; i < N; i++) scanf("%d ", &arr[i]); int del = 0; scanf("%d", &del); int j = 0; for (i = 0; i < N; i++) { if (arr[i] != del) { a[j++] = arr[i]; } } for (i = 0; i < j; i++) printf("%d ", a[i]); free(a); free(arr); return 0; }