Nine degrees OJ 1174 find K decimal (STL)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.