[蓝桥杯][2013年第四届真题]错误票据(水题)

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main(){
    
    
    ios::sync_with_stdio();
    int n; cin>>n;
    int pos = 0;
    while(n--){
    
    
        while(cin>>a[pos++]){
    
    
            if(cin.get()=='\n')
                break;
        }
    }
    int ans1,ans2;
    sort(a,a+pos);
    for(int i=1;i<pos;i++){
    
    
        if(a[i]!=a[i-1]+1&&a[i]!=a[i-1]){
    
    
             ans1 = a[i-1]+1;
             //cout<<"1!!!"<<endl;
        }

        if(a[i]==a[i-1])
            ans2 = a[i];
    }
    //cout<<pos<<endl;
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}


猜你喜欢

转载自blog.csdn.net/qq_43811879/article/details/108856913