C++ vector, what does this code mean?

前端 未结 6 1140
谎友^
谎友^ 2021-01-23 22:27

I have this code:

 const int maxnodes = 5000;
 struct Edge 
 {
   int to, rev;
   int f, cap;
 };

 vector g[maxnodes];

This is qui

6条回答
  •  逝去的感伤
    2021-01-23 23:11

    int nodes = maxnodes, src, dest;
    

    Here nodes, src, dest are all integers where nodes is initialized with maxnodes others are not initialized.

    vector g[maxnodes];
    

    As @milleniumbug mentioned g is a C array of vectors:

    g[u][j] will give i th element of u th element of array g. As u the element of g is a vector where you can access its members using [] operator.

提交回复
热议问题