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

Re:用QSORT注意点

Posted by runtoglory at 2014-06-15 16:55:29 on Problem 1328
In Reply To:用QSORT注意点 Posted by:Cleaf at 2014-02-10 22:43:23
> 因为qsort返回值为int 类型,所以不能用 return *a-*b!!这样子精度不够!
> 可以写int cmp(const void* _a,const void* _b)
> {
> 	double *a=(double*)_a;
> 	double *b=(double*)_b;
> 	if(a[0]-b[0]<0) return -1;
> 	else if(a[0]==b[0]) return 0;
> 	else return 1;
> }
> 不可以写
> int cmp(const void* _a,const void* _b)
> {
> 	double *a=(double*)_a;
> 	double *b=(double*)_b;
> return (int )*a-*b;
> }

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