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

序列中删除指定数字

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

#include<stdio.h>
int main()
{
    int n,m,i,p,s,c,o;
    scanf("%d",&n);
    int a[n],l=n;
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    scanf("%d",&m);
    for(o=0;o <n;o++)
    {
        for(c=0;c<l;c++)
            if(a[c]==m)
            {
                l--;
                break;
            }
        for(s=c;s<l;s++)
            a[s]=a[s+1];
    }
    for(p=0;p<l;p++)
        printf("%d ",a[p]);
}
全部评论

相关推荐

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