mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1857.cpp
This commit is contained in:
parent
c414226d51
commit
eb6f7b5311
41
QUSTOJ/1857.cpp
Normal file
41
QUSTOJ/1857.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
vector<int> vec;
|
||||
int n;
|
||||
cin>>n;
|
||||
int tmp;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
cin>>tmp;
|
||||
vec.push_back(tmp);
|
||||
}
|
||||
int m;
|
||||
cin>>m;
|
||||
bool flag=false;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
if(vec.at(i)==m)
|
||||
{
|
||||
flag=true;
|
||||
vec.erase(vec.begin()+i);
|
||||
for(int j=0;j<n-2;j++)
|
||||
{
|
||||
cout<<vec.at(j)<<" ";
|
||||
}
|
||||
cout<<vec.at(n-2)<<endl;
|
||||
cout<<"You deleted "<<m<<endl;
|
||||
|
||||
break;///BREAK??
|
||||
}
|
||||
}
|
||||
if(!flag)
|
||||
{
|
||||
cout<<"sorry,what you delete is not in the list."<<endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user