解题说明:此题其实只要求只有两个数是相同的,且他们出现的次数也要相同,排序之后进行判断即可.
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
int a[101];
for (int i = 0; i<n; i++)
{
cin >> a[i];
}
sort(a, a + n);
if (a[0] == a[(n / 2) - 1] && a[(n / 2)] == a[n - 1] && a[0] != a[n - 1])
{
cout << "YES\n" << a[0] << " " << a[n - 1]<<endl;
}
else
{
cout << "NO"<<endl;
}
return 0;
}