Skip to content

Instantly share code, notes, and snippets.

@haridutt12
Created March 29, 2017 10:05
Show Gist options
  • Save haridutt12/bbcbb358387fc4e085ad14d82209d6c9 to your computer and use it in GitHub Desktop.
Save haridutt12/bbcbb358387fc4e085ad14d82209d6c9 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
struct job
{
int start;
int end;
};
bool sorting(job const& lhs, job const& rhs)
{
if (lhs.start != rhs.start)
return lhs.start < rhs.start;
else
return true;
}
int main() {
int n;
cin>>n;
struct job a[n];
for(int i=0;i<n;i++)
{
cin>>a[i].start>>a[i].end;
}
sort(a,a+n,sorting);
for(int i=0;i<n;i++)
{
cout<<a[i].start<<endl<<a[i].end<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment