Sir/Mam, for some reason I am getting an error which states as 18 Bus error. I tried unlocking the solution but still, it says the same.
#include
using namespace std;
int main() {
int nRow,nCol;
cin >> nRow >> nCol;
int a[nRow][nCol];
//Take Input
for (int i = 0; i < nRow; i++) {
for (int j = 0; j < nCol; j++) {
cin >> a[i][j];
}
}
//Iterating over each column
for (int j = 0; j < nCol; j++) {
//for odd columns printing elements of rows from max row to min row
//for even columns printing elements of rows from min row to max row
//Thus forming a wave pattern.
if( j%2!=0){
//for odd column
for (int i = nRow-1; i >= 0; i–) {
cout << a[i][j] << ", ";
}
}else{
//for even column
for (int i = 0; i < nRow; i++) {
cout << a[i][j] << ", ";
}
}
}
cout << “END” <<endl;
}
Even my solution was the same as sir explained.