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
|
#include<iostream>
using namespace std;
int main()
{
int m,n;cin>>m>>n;
int a[m][n];
for(int i = 0;i < m;i ++ )
for(int j = 0;j < n;j ++ )
cin>>a[i][j];
int k = 0,t;
while(k<m)
{
for(int i = 0;i < m;i ++ )
for(int j = 0;j < n-1;j ++ )
if(a[i][j]>a[i][j+1])
{
t = a[i][j];
a[i][j] = a[i][j+1];
a[i][j+1] = t;
}
k++;
}
for(int i = 0;i < m;i ++ )
{
for(int j = 0;j < n;j ++ )
cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}
|