1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// deck2.0.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cstdlib> // needed for rand() and srand()
#include <ctime> // needed for time()
using std::cout; using std::endl;
int getcard(int deck []) {
int m;
for (m=0; m<=52; m++)
return deck[m];
}
int main()
{
int deck[52]={2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,
10,10,10,10,11,11,11,11}; // An array of 52 integers. deck 52 cards
int i,n,temp,x; // variable used as array INDEX, to select which array element.
srand(time(NULL)); // seed for random function
// set each of the 52 cards to a random value
// print all 52 cards
for (i=0; i<52; i++){
cout<<deck[i]<<" ";
}
cout<<endl;cout<<endl;
for (n=0; n<1040; n++){
int k = rand()%52;
int l = rand()%52;
temp=deck[k];
deck[k]=deck[l];
deck[l]=temp;
}
for (i=0; i<52; i++){
cout<<deck[i]<<" ";
}
cout<<endl;cout<<endl;
cout<<getcard(x);
}
|