Advertisement
SelinD

ex15

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