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:省略最后参数的时候就使用 < ,很多stl函数都这样的,比如make_heap!

Posted by kansas at 2005-11-27 21:00:33
In Reply To:难道是这里出的问题? Posted by:Spacesheep at 2005-11-27 20:32:26
> #include <iostream>
> #include <fstream>
> #include <algorithm>
> #include <vector>
> using namespace std;
> 
> using namespace std;
> 
> class Seq
> {
> public:
> 	int org,cost;
> 	inline bool operator < (Seq &b)
> 	{
> 		if (this->cost < b.cost)
> 		{
> 			return true;
> 		}
> 		return false;
> 	}	    
> };
> 
> bool cmp(Seq a,Seq b){
> return a.cost<b.cost;
> }
> 
> int main ()
> {
> 	freopen ("test.txt","r",stdin);
> 	Seq array[10];
> 
> 	int i;
> 
> 	for (i = 0;i < 10;i++)
> 	{
> 		cin >> array[i].cost;
> 		array[i].org = i;
> 	}
> 	sort (array,array + 10,cmp);//注意这里
> 	
> 	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