home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
borland
/
cb
/
setup
/
cbuilder
/
data.z
/
DEQUE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1997-02-28
|
992b
|
51 lines
#include <deque>
#include <string>
using namespace std;
deque<string> deck_of_cards;
deque<string> current_hand;
void initialize_cards(deque<string>& cards)
{
cards.push_front("aceofspades");
cards.push_front("kingofspades");
cards.push_front("queenofspades");
cards.push_front("jackofspades");
cards.push_front("tenofspades");
//
// etc.
//
}
template <class It, class It2>
void print_current_hand(It start, It2 end)
{
while (start < end)
cout << *start++ << endl;
}
template <class It, class It2>
void deal_cards(It, It2 end)
{
for (int i=0;i<5;i++)
{
current_hand.insert(current_hand.begin(),*end);
deck_of_cards.erase(end++);
}
}
void play_poker()
{
initialize_cards(deck_of_cards);
deal_cards(current_hand.begin(),deck_of_cards.begin());
}
int main ()
{
play_poker();
print_current_hand(current_hand.begin(),current_hand.end());
return 0;
}