结构体为下标(map实现)

#include<bits/stdc++.h>
using namespace std;
struct Node
{
    int a;
    int b;
    bool operator<(const Node temp)const{    //加个比较函数就行
        if(a==temp.a) return b<temp.b;
        return a<temp.a;
    }
}x;
map<Node,int>mp;
int main()
{
    x.a=1;
    x.b=2;
    mp[x]=1;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/m0_58177653/article/details/120027365
今日推荐