For C arrays, you'll probably want to use memset
. You've marked this as C++, though, so I feel obliged to give a C++ answer:
std::vector<std::vector<int>> v(10, std::vector<int>(10, 45));
This creates a std::vector
of 10 std::vector<int>
s of size 10 with each element initialized to 45.
See here for the ideone.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…