1144 The Missing Number(20 分)
2018-08-05 本文已影响0人
zjh3029
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n, m,out;
vector<int> v;
cin >> n;
for (int i = 0; i <n; i++)
{
cin >> m;
if (m>0)
{
v.push_back(m);
}
}
sort(v.begin(), v.end());
int c_before = 0;
for (auto c : v)
{
if (c==c_before||c==(c_before+1))
{
c_before = c;
}
else
{
break;
}
}
cout << c_before+1 << endl;
system("pause");
return 0;
}