题解 | #序列中删除指定数字#
序列中删除指定数字
https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7
#include <stdio.h> int main() { int a = 0; scanf("%d",&a); int arr1[50] = {0}; for (int i = 0; i < a; i++) { scanf("%d ",&arr1[i]); } int b = 0; scanf("%d",&b); for (int i = 0; i < a; i++) { if (arr1[i] == b) { arr1[i] = 'a'; //借助题解某位哥们的思路改进 } } for (int i = 0; i < a; i++) { if (arr1[i] != 'a') { printf("%d ",arr1[i]); } } return 0; }