Computer Science, asked by abhinavmore2609, 1 year ago

Write a program for row wise sort for a square matrix?

Answers

Answered by RahulMalkani
0
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr.length;j++)
{
for(int k=j+1;k<arr.length;k++)
{
if(arr[i][j] > arr[i][k])
{
int temp = arr[i][j];
arr[i][j] = arr[i][k];
arr[i][k] = temp;
}
}
}
}

It will sort each row in ascending order. I wrote this program in comment section here. If there is any error let me know. I will help you to solve it.
Similar questions