Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

DZone's Guide to

# A Solution For The "Stack 'em Up" Problem

·
Free Resource

Comment (0)

Save
{{ articles[0].views | formatCount}} Views
```A solution for the "Stack 'em Up" problem.

Problem description:
http://icpcres.ecs.baylor.edu/onlinejudge/external/102/10205.html

Author: Joana Matos Fonseca da Trindade
Date: 2008.04.05
```
/*
* Solution for "Stack 'em Up" problem.
* UVa ID: 10205
*/
#include

#define NVALUES 13
#define NSUITS 4
#define NCARDS 52
#define NSHUFFLES 100
#define WSIZE 9

using namespace std;

char values[NVALUES][WSIZE] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};
char suits[NSUITS][WSIZE] = {"Clubs", "Diamonds", "Hearts", "Spades"};
int shuffles[NSHUFFLES][NCARDS];
int deck[NCARDS];

/* read all dealer shuffles */
for(int i=0; i

> shuffles[i][j];
}
}
}

/* shuffle the deck with one of the known shuffles */
void shuffle_deck(int s_id) {
int tmpdeck[NCARDS];
for (int i=0; i

> nc;

for (int i=0; i

> ns;

/* initialize deck */
for (int p=0; p

> s;
shuffle_deck(s - 1);
}

/* print deck */
for (int k=0; k

``````
Topics:

Comment (0)

Save
{{ articles[0].views | formatCount}} Views

Opinions expressed by DZone contributors are their own.