蓝桥杯练习题-历届试题-错误票据

#include   
#include   
#include
using namespace std;
int n;
char a;
char b;
int x;
int num[10005];
char s[10000];
int main()
{
    string k;
    cin >> n;
    int nn = n;
    getchar();
    int i = 0;
    int f = 0;
    while (nn--)
    {
        getline(cin, k);
        for (int j = 0; j< k.length(); j++)
        {
            a = k[j];
            if (a >= '0'&&a <= '9')//数字
            {
                x = x * 10 + a - '0';
                f = 1;
            }
            if (a ==' '&&f == 1)//等于空格,有数字
            {
                num[i] = x;
                i++;
                x = 0;
                f = 0;
            }

        }
        if (f)
        {
            num[i] = x;
            i++;
            x = 0;
            f = 0;
        }
    }
    sort(num, num + i);
    int x1, x2,x3;
    x1 = num[0];
    for (int j = 1; j < i; j++)
    {
        if (x1 != num[j]-1)
        {
            if (x1 == num[j])
            {
                x3 = num[j];
            }
            else
            x2 = num[j]-1;//断号ID;
        }
        x1 = num[j];
    }
    cout << x2 << " " << x3 << endl;
    return 0;
}

你可能感兴趣的:(蓝桥杯练习题-历届试题-错误票据)