this code give run time error
$ Sum Of All Submatrix From A given Matrix - Approach 1 Search Contents.. search < Dashboard
Hello @khemchandrs,
There are multiple problems in your code:
-
You have to write #include before using namespace std; else it will give error.
-
You have not called the function sub_matrix_sum() inside main()
-
The way you are assigning values to vector is incorrect.
There are two ways of doing it:
3.1.
vector<vector > v;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
v[i].push_back(1);
}}
3.2.
vector<vector > v;
for(int i=0;i<n;i++){
vector x;
for(int j=0;j<m;j++){
x.push_back(1);
}
v.push_back(x);
}
Hope, this would help.
Give a like if you are satisfied.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.