代码如下:
#include <cstdio>
using namespace std;
const int MAX = 1009;
int main() {
int t;
scanf("%d", &t);
while (t > 0) {
int n;
scanf("%d", &n);
int fi = 1, si = 0, num[MAX] = {0};
for (int i = 0; i < n; i++) {
scanf("%d", &num[i]);
if (num[i] > fi) {
si = fi;
fi = num[i];
}
else if (num[i] < fi){
if (num[i] > si) si = num[i];
}
}
printf("%d %d\n", fi, si);
t--;
}
return 0;
}