Advertisement
Plabon_dutta

UVA 10205 - Stack 'em Up

Apr 25th, 2021
141
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.  
  3. int shuff[100][53], card[53];
  4. void change(int n) {
  5.     static int tmp[53], i;
  6.     for(i = 1; i <= 52; i++)
  7.         tmp[i] = card[shuff[n][i]];
  8.     for(i = 1; i <= 52; i++)
  9.         card[i] = tmp[i];
  10. }
  11. void print() {
  12.     static char num[][10] = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9",
  13.         "10", "Jack", "Queen", "King"};
  14.     static char suit[][10] = {"Clubs", "Diamonds", "Hearts", "Spades"};
  15.     static int i;
  16.     for(i = 1; i <= 52; i++) {
  17.         printf("%s of %s\n", num[card[i]%13], suit[(card[i]-1)/13]);
  18.     }
  19. }
  20. int main() {
  21.     int t, n;
  22.     int i, j, k;
  23.     char line[50];
  24.     scanf("%d", &t);
  25.     while(t--) {
  26.         scanf("%d", &n);
  27.         for(k = 1; k <= n; k++) {
  28.             for(i = 1; i <= 52; i++) {
  29.                 scanf("%d", &shuff[k][i]);
  30.             }
  31.         }
  32.         for(i = 1; i <= 52; i++)
  33.             card[i] = i;
  34.         gets(line);
  35.         while(gets(line)) {
  36.             if(line[0] == '\0') break;
  37.             sscanf(line, "%d", &n);
  38.             change(n);
  39.         }
  40.         print();
  41.         if(t)
  42.             puts("");
  43.     }
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement