Created
May 24, 2014 03:41
-
-
Save lispc/13993fd7d1211bee5627 to your computer and use it in GitHub Desktop.
C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<string> | |
#include<fstream> | |
#include<cstdlib> | |
#include<cstring> | |
#include<vector> | |
#include<utility> | |
#include<unistd.h> | |
#include<algorithm> | |
using namespace std; | |
struct Result{ | |
int position; | |
int length; | |
Result(int position,int length){ | |
this->position = position; | |
this->length = length; | |
} | |
void show() const{ | |
cout<<position<<" "<<length<<endl; | |
} | |
}; | |
bool _comp(const Result & a,const Result & b){ | |
//cout<<"<=="<<endl; | |
//a.show(); | |
//b.show(); | |
//cout<<"==>"<<endl; | |
if(a.position<b.position) | |
return true; | |
if(a.length<b.length) | |
return true; | |
return false; | |
} | |
int main(int argc,char** argv){ | |
vector<Result> global_res; | |
global_res.push_back(Result(15,15)); | |
global_res.push_back(Result(15,16)); | |
global_res.push_back(Result(14,17)); | |
global_res.push_back(Result(15,17)); | |
global_res.push_back(Result(14,18)); | |
global_res.push_back(Result(13,19)); | |
global_res.push_back(Result(15,18)); | |
for(int i=0;i<global_res.size();i++){ | |
global_res[i].show(); | |
} | |
cout<<"=="<<endl; | |
sort(global_res.begin(),global_res.end(),_comp); | |
for(int i=0;i<global_res.size();i++){ | |
global_res[i].show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment