题解 | #序列中删除指定数字#
序列中删除指定数字
https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7
#include<stdio.h> #include<string.h> int main() { int n,m,i,t; int a[51] = { 0 }; t = 0; scanf("%d", &n); for (i = 0;i <= n-1;i++) { scanf("%d", &a[i]); } scanf("%d", &m); for (i = 0;i < n-t;i++) { if (m == a[i]) { memcpy(&a[i], &a[i + 1], 4 * (n - i - 1)); i = i - 1; t++; } } for (i = 0;i < n-t;i++) { printf("%d ", a[i]); } return 0; }