//-------------------------------------------------------------------
int main()
{
	//printf("~~~~~~~MAIN FUNCTION~~~~~~~\n");
	struct Node *head = makeDeck();
	printf("-------------------------------------------------------------------------------");
	//printf("\nTHE LENGTH OF THIS DECK IS: %d\n",length(head));
	printf("Here is an ordered Deck: \n");
	printList(head);
	printf("Here is a shufled Deck: \n");
	struct Node *shuffledHead = randomShuffle(head);
	printList(shuffledHead);
}
int main ()
{
	time_t current;
	time( & current );
	srand( ( unsigned int ) current );

	const int SIZE = 10;
	int data[ SIZE ];
	for ( int i = 0; i < SIZE; i++ )
		data[ i ] = i + 1;

	printArray( data, SIZE );

	randomShuffle( data, SIZE, 1 );

	printArray( data, SIZE );

	randomShuffle( data, SIZE );

	printArray( data, SIZE );

	return 0;
}
Exemple #3
0
 /** Randomly shuffle a set of \a n elements. This implements the Fisher-Yates/Knuth shuffle. */
 template <typename T> void randomShuffle(int32 n, T * elems)
 {
   randomShuffle(n, n, elems);
 }