模板 - 结构体进阶

模板 - 结构体进阶

用了这个优化模板,就没pair什么事了

struct Node {
    int x,y,step;
    Node(int x = 0,int y = 0,int step = 0):x(x),y(y),step(step){}
};

优先队列里面的结构体有点难定义,不过这样就没问题了

//堆专用
struct Node {
    int to,cost;
    Node (int x = 0,int c = 0):to(x),cost(c){}
    bool operator < (const Node &a) const {
        return a.cost < cost;
    }
};

字符串(char*)的比较,非常麻烦,现在我所知道最好的方式就是不建二维字符串了,只使用结构体里面套字符串

struct Node{
    char name[maxn];
}peo[maxn]

猜你喜欢

转载自blog.csdn.net/qq_41428565/article/details/80069874