题解 | #删除元素#

删除元素

https://ac.nowcoder.com/acm/problem/22228

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n,m;
    while(cin>>n)
    {
        vector<int>a(n);
        for(int i=0;i<n;i++) cin>>a[i];
        cin>>m;
        auto it=find(a.begin(),a.end(),m);
        if(it!=a.end()) a.erase(it),n--;
        for(int j=0;j<n;j++) cout<<a[j]<<" ";
        cout<<endl;
    }
}
全部评论

相关推荐

不愿透露姓名的神秘牛友
昨天 17:10
什么素质,我请问呢,要掉小珍珠了。。。又憋屈又生气
Steven267:这不喷回去?花钱是大爷,记住这个道理
点赞 评论 收藏
分享
一表renzha:手写数字识别就是一个作业而已
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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