求出最大最小值,从小到大遍历,将出现的次数计入a【n】,最后输出重复和缺失的数字
···
#include<iostream>
#include<sstream>
#include<cstring>
#include <algorithm>
using namespace std;
const int N = 100100;
int n;
int a[N];
int main(){
int c,d,min1= 10010,max1=0;
int n,m;
cin >> c;
while(c--){
while(cin >> d){
a[d]++;
min1 = min(min1,d);
max1 = max(max1,d);
}
}
for(int i = min1;i < max1;i ++){
if(a[i] == 0) m = i;
else if(a[i] == 2) n = i;
}
cout << m <<" " << n;
return 0;
}
```