Advertisement
bangnokia

Sap xep

Sep 17th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. void SapXep(int A[],int N)
  2. {
  3.     int i,j;
  4.     int tam;
  5.  
  6. //vong lap sap xep ong viet sai, thay giao viet nhu nay
  7.     for(j=0;j<N-1;j++)
  8.         for(i=0;i<N-1;i++)
  9.             if(A[i]<A[i+1])
  10.             {
  11.                 tam=A[i];
  12.                 A[i]=A[i+1];
  13.                 A[i+1]=tam;
  14.             }
  15.     //in mang sau khi sap xep
  16.     for(i=0;i<N;i++)
  17.         printf("%d ",A[i]);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement