历届试题 错误票据

#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
using namespace std;
int a[100001];
int main(){
    
    memset(a, 0, 100001);
    
    int n;
    cin >> n;
    cin.get();
    string s;
    int max = -1, min = 100000;
    for (int i=0; i<n; i++) {
        getline(cin, s);
        stringstream steam(s);
        int temp;
        while (steam >> temp) {
            max = temp > max ? temp : max;
            min = temp < min ? temp : min;
            a[temp] ++;
        }
    }
    int id_m, id_n;
    for (int i=min; i<=max; i++) {
        if (a[i] == 0) {
            id_m = i;
        }
        if (a[i] == 2) {
            id_n = i;
        }
    }
    cout << id_m << " " << id_n << endl;
    return 0;
}
发布了33 篇原创文章 · 获赞 7 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/LoverJuan/article/details/88750791