Poj 2371 Questions and answers(排序)

题目链接:http://poj.org/problem?id=2371

思路分析:使用计数排序或其他时间复杂度为O( log N )的排序。

代码如下:

#include <iostream>
#include <algorithm>

#define MAX_N ( 100000 + 10 )
using namespace std;

int A[MAX_N];

int main()
{
    int n, k, i, j;
    char Tmp[5];

    cin >> n;
    for ( i = 0; i < n; ++i )
        cin >> A[i];

    sort( A, A + n );

    cin >> Tmp;
    cin >> k;
    while ( k-- )
    {
        cin >> j;
        cout << a[j-1] << endl;
    }

    return 0;
}
原文地址:https://www.cnblogs.com/tallisHe/p/4007890.html