Advertisement
Guest User

Botas - refatorado

a guest
Nov 11th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. #define MIN(a, b) ((a) < (b) ? (a) : (b))
  5.  
  6. int main(void)
  7. {
  8.     int quantidade;
  9.     while(scanf("%d",&quantidade) != EOF)
  10.     {
  11.         int *le = (int *)calloc(31,sizeof(int));
  12.         int *ld = (int *)calloc(31,sizeof(int));
  13.         int numero,pares = 0;
  14.      
  15.         while(quantidade--)
  16.         {
  17.             char lado;
  18.             scanf("%d %c",&numero,&lado);
  19.             if(lado == 'E')
  20.                 le[numero - 30]++;
  21.             else
  22.                 ld[numero - 30]++;
  23.         }
  24.         for(int a = 0; a < 30;a++)
  25.             pares += MIN(le[a],ld[a]);
  26.         printf("%d\n",pares);
  27.        
  28.         free(le);
  29.         free(ld);
  30.     }
  31.     return EXIT_SUCCESS;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement