Sir i am not able to pass the test cases i doesnot get my mistake please help me my code is below
this link doesn’t any code
resend the correct link
okk sir
Your mistakes
- print ", " (comma and space ) after each element
- don’t print endl at input
Modified Code
#include<iostream>
using namespace std;
void waveprint( int arr[][1000], int row, int col) {
int end_column = col - 1;
int end_row = row - 1;
for ( int j = 0; j <= end_column; j++) {
if (j % 2 == 0) {
for ( int i = 0; i <= end_row; i++) {
cout << arr[i][j] << ", ";
}
}
else
for ( int i = end_row; i >= 0; i--) {
cout << arr[i][j] << ", ";
}
}
cout << "END";
}
int main() {
int m, n;
//cout<<" enter no of row or column"<<endl;
cin >> m >> n;
int arr[m][1000];
for (int i = 0; i < m; i++) {
for ( int j = 0; j < n; j++) {
cin >> arr[i][j];
}
}
waveprint(arr, m, n);
return 0;
}
now it is passing all testcase
if your doubt resolved plz mark it as resolved