Advertisement
STANAANDREY

sort_mat_lines

Apr 17th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a[100][100],n,m,i,j,k,aux;
  6. cin>>n>>m;
  7. for (i=0;i<n;i++)
  8. for (j=0;j<m;j++)
  9. cin>>a[i][j];
  10.  
  11. for (k=0;k<n;k++)
  12. for (i=0;i<m-1;i++)
  13. for (j=i+1;j<m;j++)
  14. if (a[k][i]>a[k][j])
  15. {
  16.     aux=a[k][i];
  17.     a[k][i]=a[k][j];
  18.     a[k][j]=aux;
  19. }
  20. cout<<endl;
  21. for (i=0;i<n;i++) {
  22.     for (j=0;j<m;j++)
  23.     cout<<a[i][j]<<' ';
  24.     cout<<endl;}
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement