题解 | #序列中删除指定数字#
序列中删除指定数字
http://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7
int main() { int n = 0; scanf("%d", &n); int arr[50] = { 0 };
int a = 0;
int b = 0;
for (a; a < n; a++)
scanf("%d", &arr[a]);
int del = 0;
scanf("%d", &del);
for (a = 0; a < n; a++)
{
if (arr[a] != del)
arr[b++] = arr[a];
}
for (a = 0; a < b; a++)
{
printf("%d ",arr[a]);
}
return 0;
}