序列中删除指定数字

用一维数组来表示整数序列,输入被删除的数字后,每当输出到该数时continue就可以做到删除该数的效果。

#include<iostream>
using namespace std;
int main(){
    int n,c;
    cin>>n;
    int *a=new int[n+1];
    for(int b=1;b<=n;b++){
        cin>>a[b];
    }
    cin>>c;
    for(int d=1;d<=n;d++){
        if(a[d]==c){
            continue;
        }
        cout<<a[d]<<" ";
    }
    cout<<endl;
    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-27 15:19
简历上能写3个月吗?
码农索隆:大胆写,主要你能把实习经历包装好,可以看一下我这篇帖子https://www.nowcoder.com/share/jump/4888395581180798063
点赞 评论 收藏
分享
点赞 评论 收藏
分享
Gaynes:查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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