Run ID:104706
提交时间:2025-01-08 20:19:24
#include <iostream> #include <algorithm> // 用于 std::sort using namespace std; int main() { int C; cin >> C; // 读取测试数据的组数 while (C--) { int n; cin >> n; // 读取每组测试数据的整数个数 int numbers[10]; // 假设每组最多有10个整数 for (int i = 0; i < n; ++i) { cin >> numbers[i]; // 读取每组测试数据的整数 } // 对数组进行排序 sort(numbers, numbers + n); // 寻找第二小的数,如果存在重复的最小数,则跳过它 int secondMin = numbers[0]; bool found = false; for (int i = 1; i < n; ++i) { if (numbers[i] != secondMin) { found = true; break; } } // 根据是否找到第二小的数输出结果 if (found) { cout << secondMin << endl; } else { cout << "NO" << endl; } } return 0; }