Advertisement
icatalin

sortare d.p.

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