题解 | #序列中删除指定数字#

序列中删除指定数字

https://www.nowcoder.com/practice/7bbcdd2177a445a9b66da79512b32dd7

#include <stdio.h>
int main() {
    int n = 0,arr[50] = {0};
    int x = 0;
    while (scanf("%d\n", &n)!= EOF) {//输入
        for(int i = 0; i < n; i++)//输入
        {
            scanf("%d ",(arr + i));
        }
        scanf("%d",&x);//不想要的数
        for(int i = 0; i < n;i++)
        {
            if(x != arr[i])//不等于x就输出
            printf("%d ",arr[i]);
        }
    }
    return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务