Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题来的,一次AC

Posted by 382784268 at 2009-03-08 15:03:50 on Problem 2371
#include<iostream>
#include<cstdlib>
using namespace std;
int cmp(const void *a, const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	int n,k,i,j;
	char s[5];
	int *p;
	cin>>n;
	p=new int[n];
	for(i=0;i<n;i++)
		cin>>p[i];
	qsort(p,n,sizeof(int) ,cmp);
	cin>>s;cin>>k;
	int *q=new int[k];
	for(i=0;i<k;i++)
		cin>>q[i];
	j=0;
	while(j<k)
	{
		cout<<p[q[j]-1]<<endl;
		j++;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator