Can u do this code like a function
#includeint main(){ int k, n1, m1,i,j; int mat[4][4] = { { 10, 27, 35, 14 }, { 99, 54, 81, 20 }, { 63, 36, 80, 11 }, { 95, 78, 45, 37} }; for (int i = 0; i < 4;="" i++)=""> // Sort even rows in ascending order if (i % 2 == 0) { for (int m1 = 0; m1 < 4;=""> { for (int n1 = m1 + 1; n1 < 4;="" ++k)=""> if (mat[i][n1] > mat[i][m1]) { // swap adjacent element int extra = mat[i][n1]; mat[i][n1] = mat[i][m1]; mat[i][m1] = extra; } } } } else { for (int n1 = 0; n1 <4 ;="">4> { for (int m1 = n1 + 1; m1 < 4;=""> { // compare adjacent elements if (mat[i][n1] <> { // swap adjacent element int extra = mat[i][n1]; mat[i][n1] = mat[i][m1]; mat[i][m1] = extra; } } } }return 0;}}
int main()
{
int k, n1, m1,i,j;
int mat[4][4] =
{ 10, 27, 35, 14 },
{ 99, 54, 81, 20 },
{ 63, 36, 80, 11 },
{ 95, 78, 45, 37}
};
for (int i = 0; i < 4;="" i++)="">
// Sort even rows in ascending order
if (i % 2 == 0)
for (int m1 = 0; m1 < 4;="">
for (int n1 = m1 + 1; n1 < 4;="" ++k)="">
if (mat[i][n1] > mat[i][m1])
// swap adjacent element
int extra = mat[i][n1];
mat[i][n1] = mat[i][m1];
mat[i][m1] = extra;
}
else {
for (int n1 = 0; n1 <4 ;="">4>
for (int m1 = n1 + 1; m1 < 4;="">
// compare adjacent elements
if (mat[i][n1] <>
return 0;
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here