nikolas_serafini

Lista 4 - Exercício 13

Jun 21st, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int unison[200],size = 0,i,j,k,testNumber,aux;
  6.  
  7.     while (1)
  8.     {
  9.         printf("Entre com um elemento para o primeiro conjunto : (-1 para sair)\n");
  10.         scanf("%d",&testNumber);
  11.         if (testNumber == -1)
  12.             break;
  13.         unison[size] = testNumber;
  14.         size++;
  15.     }
  16.     while (1)
  17.     {
  18.         printf("Entre com um elemento para o segundo conjunto : (-1 para sair)\n");
  19.         scanf("%d",&testNumber);
  20.         if (testNumber == -1)
  21.             break;
  22.         unison[size] = testNumber;
  23.         size++;
  24.     }
  25.    
  26.     k = size-1;
  27.     for (i = 0; i < size; i++)
  28.     {
  29.         for (j = 0; j < k; j++)
  30.         {
  31.             if (unison[j] > unison[j+1])
  32.             {
  33.                 aux = unison[j];
  34.                 unison[j] = unison[j+1];
  35.                 unison[j+1] = aux;
  36.             }
  37.         }
  38.         k--;
  39.     }
  40.     printf("\n");
  41.     for (i = 0; i < size; i++)
  42.     {
  43.         printf("%d\n",unison[i]);
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment