List of all available Websheets
Viewing cpp/vectors/matrix by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Defining vectors-of-vectors with a given size. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; void print_matrix(vector<vector<int> > M) { for (int r=0; r<\[M.size()]\; r++) { for (int c=0; c<\[M[0].size()]\; c++) { cout << M[r][c] << " "; } cout << endl; } } int main() { // create a 3-by-3 matrix of zeros vector<vector<int> > nine_zeros(3, vector<int>(3, 0)); // create a 2 row, 4 column matrix of ones vector<vector<int> > two_by_four\[(2, vector<int>(4, 1))]\; print_matrix(nine_zeros); cout << endl; print_matrix(two_by_four); } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [ {} ] |
Solution visibility |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.