Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int a[100][100],n,i,j,x,m,aux,OK;
- cout<<"n= ";cin>>n;
- cout<<"m= ";cin>>m;
- for (i=1;i<=n;i++)
- for (j=1;j<=m;j++)
- {
- cout<<"a["<<i<<"]["<<j<<"]= ";
- cin>>a[i][j];
- }
- do
- {
- OK=1;
- for (x=1;x<=n;x++)
- for (i=1;i<=n-1;i++)
- for (j=1;j<=m-1;j++)
- if (a[x][j]>a[x][j+1])
- {
- aux=a[x][j];
- a[x][j]=a[x][j+1];
- a[x][j+1]=aux;
- OK=0;
- }
- }while (OK!=1);
- for (i=1;i<=n;i++)
- {for (j=1;j<=m;j++)
- cout<<a[i][j]<<" ";
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement