+ 1
Snake format matrix
/* Given integers n and m. Create an array A [n] [m] and fill it with numbers in a snake form (look at example). Input 4 6 Output 0 1 2 3 4 5 11 10 9 8 7 6 12 13 14 15 16 17 23 22 21 20 19 18 Help !*/ #include <iostream> using namespace std; int main() { int m, n; cin >> n >> m; int mat[1000][1000]; //idk what i have to write here... for (int i = 0; i < n; i++) { if (i % 2 == 0) { for (int j = 0; j < m; j++) cout << mat[i][j] << " "; } else { for (int j = m - 1; j >= 0; j--) cout << mat[i][j] << " "; } } }
1 Answer
0
You need to populate the matrix mat with the appropriate values before printing it in snake format. Check this out⤾ď¸
https://sololearn.com/compiler-playground/cKD7wu9239yl/?ref=app