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

序列中删除指定数字

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

#include <stdio.h>

int main() {
   int n = 0;
   scanf("%d", &n);
   int arr[100] = {0};
   for(int i = 0; i < n; i++)
   {
    scanf("%d ", &arr[i]);
   }
   int num = 0;
   scanf("%d", &num);

    int j = 0;
    for(int i = 0; i < n; i++)
    {
        if(num != arr[i])
        {
            arr[j] = arr[i];
            j++;
        }
    }

    for(int i = 0; i < j; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-25 19:15
点赞 评论 收藏
分享
05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
就在我现在公司的隔壁每天经过都唏嘘不已(就是羡慕)什么时候可以到这里上班啊
柯基在debug:从大学毕业投简历到现在了,应届的时候我都面到终面了,现在工作四年了连简历初筛都过不了了
投递莉莉丝游戏等公司7个岗位 >
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务