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

序列中删除指定数字

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

#include <stdio.h>

int main() {
    int n,x;
    scanf("%d",&n);
    int arr[100];
    for(int i=0;i<n;i++)
    {
        scanf("%d ",&arr[i]);
    }
    scanf("%d",&x);
    for(int k=0;k<n;k++)
    {
        if(x==arr[k])//遇见要删除的数就跳过此次循环,不打印
        {
            continue;
        }
        printf("%d ",arr[k]);
    }
    return 0;
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务