please explain sir cant get it??
How to approach
hello @ahujaxrhythm
The algorithm for this problem is simple
a) first u need to read the dimension of the matrix say (M XN)
b) after that u need to read the matrix
c) and then for every even column(column number starts from 0 ) print top to bottom and for every odd column print bottom to top.
#include<iostream>
using namespace std;
int main() {
int M,N;
cin>>M>>N; //reading dimesnions
int arr[100][100];
for(int i=0;i<M;i++){ //reading matrix
for(int j=0;j<N;j++){
cin>>arr[i][j];
}
}
for(int i=0;i<N;i++){ // itearting columwise
if(i%2==0){ // for even column
for(int j=0;j<M;j++){ //printing top to bottom
cout<<arr[j][i]<<", ";
}
}
else{ //for odd column
for(int j=M-1;j>=0;j--){ //printing bottom to top
cout<<arr[j][i]<<", ";
}
}
}
cout<<"END";
return 0;
}