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

用库函数快排,为何RuntimeError

Posted by 2006141329 at 2007-12-08 10:02:36 on Problem 2371
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int cmp ( const void *a , const void *b )
{
	return *(int *)a - *(int *)b;
}
main()
{
	int n;
	scanf("%d",&n);
	int i;
	int num[10000];
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	qsort(num,n,sizeof(num[0]),cmp);
	char s[3];
	scanf("%s",s);
	int k;
	scanf("%d",&k);
	int a;
	while(k--)
	{
		scanf("%d",&a);
		printf("%d\n",num[a-1]);
	}


}

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