题解 | #查找第K小数#
查找第K小数
https://www.nowcoder.com/practice/204dfa6fcbc8478f993d23f693189ffd
#include <iostream> using namespace std; int main() { int n; while (scanf("%d", &n) != EOF) { int arr[1010] = {0}; for (int i = 0; i < n; i++) { int t; cin >> t; arr[t]++; } int K; cin >> K; for (int i = 0; i < 1010; i++) { if (arr[i] != 0) { K--; } if (K == 0) { cout << i << endl; break; } } } return 0; }