My code is not passing the test cases but after giving custom input it gives correct answer.
Cant understand the error
@itiikhare, share your code if u want me to fix it or u can refer to https://ide.codingblocks.com/s/657739 ive commented in detail the code
#include
using namespace std;
void waveprint(int a[][100],int m,int n){
for(int c=0;c<m;c++){
if(c%2==0){
for(int r=0;r<n;r++){
cout<<a[r][c]<<", β;
}
}
else{
for(int r=n-1;r>=0;rβ){
cout<<a[r][c]<<β, ";
}
}
}
cout<<βENDβ<<endl;
}
int main() {
int m,n;
cin>>m>>n;
int a[100][100]={0};
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>a[i][j];
}
}
waveprint(a,m,n);
}
@itiikhare,
i guess in the question m and n are reversed
else your code is correct
reverse m and n see here https://ide.codingblocks.com/s/657747
next time use cb online ide for code sharing as its difficult to read
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.