Create 1857.cpp

pull/45/head
Kirigaya Kazuto 2016-11-17 09:42:10 +08:00 committed by GitHub
parent c414226d51
commit eb6f7b5311
1 changed files with 41 additions and 0 deletions

41
QUSTOJ/1857.cpp Normal file
View 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;
}