Advertisement
weldisalves

Lista 04 - exercício 09

Jun 19th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 5
  3.  
  4. //9. Leia um conjunto de números. Exiba-os em ordem numérica crescente.
  5.  
  6. int main()
  7. {
  8.     int conjunto[5]={2,3,5,1,0},i,j,aux;
  9.  
  10.     for(i=0;i<MAX;i++)
  11.     {
  12.         for(j=0;j<MAX-1;j++)
  13.         {
  14.             if(conjunto[j]>conjunto[j+1])
  15.             {
  16.                 aux=conjunto[j];
  17.                 conjunto[j]=conjunto[j+1];
  18.                 conjunto[j+1]=aux;
  19.             }
  20.         }
  21.     }
  22.     for(i=0;i<MAX;i++)
  23.     {
  24.         printf("\n %d",conjunto[i]);
  25.     }
  26.  
  27.     getchar();
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement