Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef struct test
- {
- int first_val;
- int second_val;
- }test;
- bool func(test a,test b)
- {
- if(a.second_val<b.second_val)
- return 1;
- else return 0;
- }
- int main()
- {
- test arr[] = { {5,6} , {8,1} , {6,4} , {4,9} , {2,9} , {7,3} };
- int n=sizeof(arr)/sizeof(test);
- sort(arr,arr+n,func);
- for(int i=0;i<n;i++)
- {
- cout<<arr[i].first_val<<" "<<arr[i].second_val<<endl;
- }
- }
Add Comment
Please, Sign In to add comment