Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
printAllPathsInMatrix
//Title of this code #include <iostream> #include <vector> using namespace std; template<int rows, int cols> void printAllPaths(vector<int> v, int t[rows][cols], int i, int j) { v.push_back(t[i][j]); if ((i == rows - 1) && (j == cols -1)) { for (auto it = v.begin(); it != v.end(); ++it) cout << *it << " "; cout << endl; return; } if (i < rows - 1) printAllPaths<rows, cols>(v, t, i + 1, j); if (j < cols - 1) printAllPaths<rows, cols>(v, t, i, j + 1); } int main() { int t[3][4] = { {1, 2, 3, 4 }, {5, 6, 7, 8 }, {1, 2, 3, 4 } }; vector<int> v; printAllPaths<3, 4>(v, t, 0, 0); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Kth smallest element
Cuantos dedos
override
nearest
ClassQuiz
cppPySlots3
Test 12(2020)
PATRA_Class_test
Calc
Iviewb
Please log in to post a comment.