| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:qsort那个函数怎么用?哪位大虾帮忙看一下,谢了!In Reply To:qsort那个函数怎么用?哪位大虾帮忙看一下,谢了! Posted by:xiedf at 2006-03-28 20:57:33 #include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){return *(int*)a-*(int*)b;}
int A[10000];
int main()
{
int N,M,i,j,re;
scanf("%d%d",&N,&M);
for(i=0;i<N;i++)scanf("%d",&A[i]);
qsort(A,N,4,cmp);
for(i=re=0,j=N-1;i<=j;j--)
{
if(A[i]+A[j]<=M)i++;
re++;
}
printf("%d",re);
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator