Advertisement
SelinD

ex16

May 23rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 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;
  7. for(i=1;i<=n;i++)
  8. for(j=1;j<=n;j++)
  9. cin>>a[i][j];
  10.  
  11. for(i=1;i<=n;i++)
  12. {
  13. for(j=i+1;j<=n;j++)
  14. {
  15. if(a[i][i]<a[j][j])
  16. {
  17. aux=a[i][i];
  18. a[i][i]=a[j][j];
  19. a[j][j]=aux;
  20. }
  21. }
  22. }
  23. for(i=1;i<=n;i++)
  24. {
  25. for(j=1;j<=n;j++)
  26. cout<<a[i][j]<<" ";
  27. cout<<endl;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement