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

用C的童鞋千万别写int cmp(const void *a,const void *b)!!

Posted by PoPoQQQ at 2014-03-06 13:31:26 on Problem 3696
int cmp(const void *a,const void *b)
{
    return *(long long *)a-*(long long *)b;
}
这么写排不对,因为a-b是longlong型,转成int会爆
要写
int cmp(const void *a,const void *b)
{
    return *(long long *)a>*(long long *)b?1:-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