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

用qsort加int就能过!--第一次试着用qsort!

Posted by ngn999 at 2008-07-24 15:16:11 on Problem 2388
#include <stdio.h>
#include <stdlib.h>

int cmp(int *a, int *b){
	return *a - *b;
}

int main(){
	int n, i;
	int abc[10000];

	scanf("%d", &n);

	for(i = 0; i < n; i++){
		scanf("%d", abc+i);
	}
	qsort((void *)abc, n, sizeof(int),(int (*)(const void *a, const void *b))(cmp));
	printf("%d\n",abc[n / 2]);
	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