How to initialize a 2D array with all values same?

后端 未结 6 1684
独厮守ぢ
独厮守ぢ 2021-01-29 10:49

I want to initialize a 2D array with -1 as all the value. I used memset() for this.

#include 
using namespace std;

int dp[100]         


        
6条回答
  •  Happy的楠姐
    2021-01-29 11:26

    for (auto& v : dp) {
        std::fill(std::begin(v), std::end(v), -1);
    }
    

    Inside function, not global scope.

提交回复
热议问题