I’m new to c++ and I’m currently wanting to make a 2d vectors (it’s my first time).
#include <cstdio>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
int m = 2;
int n = 5;
vector<vector<int>> test(n, vector<int>(m,10));
for (int i = 0; i < m; ++i) {
for (int k = 0; k < m; k++) {
printf("%dn", test[i][k]);
}
}
return 0;
}
here’s the code, I’, expecting m to be “row”, n to be “collumn”, all of the values are 10, and I wanted to print them out as well, it only prints 5 “10”, I don’t know what I messed up here.
I really don’t know
New contributor
trần gia bảo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.