Topic 1174: Find the K decimal
time limit:1 seconds
Memory limit:32 MB
Special question: No
submitted:5161
Resolution:2081
-
Title Description:
-
Look for a small number of k in an array, and note the same size as large.
such as 2 1 3 4 5 2 The third decimal is 3.
-
Input:
-
Enter more than one set of data.
Enter n for each group, enter n integers (1<=n<=1000), and then enter K.
-
Output:
-
Output a small integer of K.
-
Sample input:
-
62 1 3 5 2 23
-
-
Sample output:
-
-
3
According to test instructions, because the same size, the calculation is as large, so, after the order to go heavy.
#include <iostream> #include <algorithm> #include <stdio.h>using Namespace Std;int a[1001];int Main (int argc, char *argv[]) {freopen ("1174.in", "R", stdin); int n,k; while (~SCANF ("%d", &n)) {for (int i=0;i<n;++i) scanf ("%d", &a[i]); Sort (a,a+n); Unique (a,a+n); scanf ("%d", &k); printf ("%d\n", a[k-1]);
} return 0;}
stl is to remove adjacent repeating elements (one only)
Nine degrees OJ 1174 find K decimal (STL)