美文网首页
1144 The Missing Number(20 分)

1144 The Missing Number(20 分)

作者: zjh3029 | 来源:发表于2018-08-05 15:21 被阅读0次
#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;
}

相关文章

网友评论

      本文标题:1144 The Missing Number(20 分)

      本文链接:https://www.haomeiwen.com/subject/orubvftx.html