Secret (secret. pas) and Secret (secret. pas)
Military secrets(Secret. pas)[Problem description]The information intercepted by the military consists of n (n <= 30000) digits. It is a high-end secret of the enemy, so it cannot be cracked for a moment. The original idea is to sort the n numbers in ascending order. Each number corresponds to a sequence number and is interested in the number I. Now programming is required.[Input format]The first line is n, followed by n intercepted numbers, the next line is the number k, and then the number of the number to be output in k rows.[Output format]Number corresponding to the number of k rows.[Input example]Secret. in5121 1 126 123 73243[Output example]Secret. out7123121
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 int a[10001]; 5 int main() 6 { 7 int n; 8 cin>>n; 9 for(int i=1;i<=n;i++)10 {11 cin>>a[i];12 }13 sort(a+0,a+n+1);14 int k;15 cin>>k;16 for(int i=1;i<=k;i++)17 {18 int d;19 cin>>d;20 cout<<a[d]<<endl;21 }22 return 0;23 }