Advertisement
Guest User

blz

a guest
Oct 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct baralho
  5. {
  6.   char personagem[41], personagem2[41];
  7.   int k,j,y[50];
  8.  
  9. };
  10.  
  11. int main()
  12. {
  13.   struct baralho vsf[50];
  14.   struct baralho aux;
  15.   int n,i,j;
  16.   int count = 0;
  17.   char sorteio[50];
  18.  
  19.   scanf("%d",&n);
  20.  
  21.   for (i = 0; i < n; i++)
  22.   {
  23.     //  printf("\n");
  24.       scanf(" \n%[^\n]",vsf[i].personagem );
  25.  
  26.       scanf("%d",&vsf[i].k );
  27.  
  28.       for (j = 0; j < vsf[i].k; j++)
  29.       {
  30.           scanf("%d",&vsf[i].y[j] );
  31.       }
  32.  
  33.       scanf(" \n%[^\n]",vsf[i].personagem2 );
  34.       //printf("\n");
  35.   }
  36.  
  37.   for ( i = 0; i < n- 1; i++)
  38.    {
  39.      for ( j = i + 1; j < n; j++)
  40.      {
  41.        if(strcmp(vsf[i].personagem,vsf[j].personagem) > 0)
  42.        {
  43.          aux = vsf[i];
  44.          vsf[i] = vsf[j];
  45.          vsf[j] = aux;
  46.        }
  47.      }
  48.    }
  49.    scanf(" %[^\n]s", sorteio );
  50.  
  51.    for (i = 0; i < n; i++)
  52.    {
  53.      if (strcmp(sorteio,vsf[i].personagem)==0)
  54.      {
  55.        printf("contador: %d\n",i );
  56.      }
  57.      for (j = 0; j < vsf[i].k; j++)
  58.      {
  59.        printf("carta: %d\n",vsf[i].y[j % vsf[i].k]);
  60.        break;
  61.      }
  62.    }
  63.  
  64.   return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement