-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23_Row_Wise_Sort_2Darray.cpp
More file actions
55 lines (48 loc) · 1.17 KB
/
Copy path23_Row_Wise_Sort_2Darray.cpp
File metadata and controls
55 lines (48 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
using namespace std;
// #define M 12;
void rowWiseSort(int martix[][3], int rows, int cols)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = j + 1; k <=3; k++)
{
if (martix[i][j] > martix[i][k])
{
swap(martix[i][j], martix[i][k]);
}
}
}
}
cout<<"Your matrix after sort is:"<<endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cout << martix[i][j] << " ";
}
cout << endl;
}
}
int main()
{
// int rows;
// cout << "enter the numbers of rows:" << endl;
// cin >> rows;
// int cols;
// cout << "enter the numbers of cols" << endl;
// cin >> cols;
int arr[3][3];
cout << "enter the elements of the matrix" << endl;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> arr[i][j];
}
}
rowWiseSort(arr,3,3);
return 0;
}