Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*i am not gonna
- lose this time*/
- #include <bits/stdc++.h>
- using namespace std;
- #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
- #define ll long long
- #define ull unsigned long long
- #define INF INT_MAX
- #define INM INT_MIN
- #define mp make_pair
- #define pb push_back
- #define lb lower_bound
- #define ub upper_bound
- #define F first
- #define S second
- #define st(x) x.begin(),x.end()
- #define sz(x) (int)(x).size()
- #define bitcount(x) __builtin_popcountll(x)
- #define f(i,n) for(int i=0;i<n;i++)
- #define f1(i,n) for(int i=1;i<=n;i++)
- int main()
- {
- fast;
- /* pair <string,double> PAIR2 ("GeeksForGeeks", 1.23);
- cout << PAIR2.first << " " ;
- cout << PAIR2.second << endl ;
- PAIR3 = make_pair ("GeeksForGeeks is Best",4.56);
- g2.first = ".com";
- g2.second = 2;
- pair <string, int> g3(g2);*/
- pair<ll,ll>ar[n]; //declaration of pair of array;
- vector<pair<int,int>>v(n); //declaration of pair of vectors
- for(int i=0;i<n;i++){
- cin>>a>>b;
- ar[i].first=a;
- ar[i].second=b;
- v[i]=make_pair(a,b);
- v[i]={a,b};
- v.push_back(make_pair(a,b));
- }
- vector<pair<int,int>>v{{1,2},{2,3}};
- //PRINTING VECTOR AND ARRAY PAIRS
- vector<pair<int,int>>::iterator it;
- for(it=v.begin();it!=v.end();it++)
- cout<<it->first<<" "<<it->second<<" ";
- for(auto it:v)
- cout<<it.first<<" "<<it.second<<" ";
- for(auto i=0;i<v.size();i++)
- cout<<v[i].first<<" "<<v[i].second<<" ";
- for(int i=0;i<n;i++){
- cout<<ar[i].first<<" ";
- cout<<ar[i].second<<" ";
- }
- pair1.swap(pair2); //swap pair values
- //SORT PAIR
- sort(v.begin(),v.end()); //sort by first elements
- sort(v.begin(),v.end(),sortbysec);
- bool sortbysec(pair<int,int> a,pair<int,int> b)
- {
- return b.second>a.second;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment