Created
April 21, 2014 09:43
-
-
Save samebchase/11137784 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
using std::vector; | |
using std::cout; | |
using std::endl; | |
using std::cin; | |
int main(void) | |
{ | |
int rows, cols; | |
cin >> rows >> cols; | |
cout << "rows: " << rows << ", cols: " << cols << endl; | |
vector<vector<int>> matrix; | |
vector<int> row; | |
for (int row_idx = 0; row_idx < rows; ++row_idx) { | |
for (int col_jdx = 0; col_jdx < cols; ++col_jdx) { | |
int tmp; | |
cin >> tmp; | |
row.push_back(tmp); | |
} | |
matrix.push_back(row); | |
row.clear(); | |
} | |
for (auto row : matrix) { | |
for (auto elt : row) { | |
cout << elt << " "; | |
} | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample data