📄 wex3_8.cpp
字号:
#include <iostream.h>
#pragma hdrstop
#include "wex3_8.h"
void Swap (int &x, int &y)
{
int temp;
temp = x;
x = y;
y = temp;
}
// order an integer array using the exchange sort
void Sort(int a[], int size)
{
int i, j;
for (i = 0; i < size-1; i++)
for (j = i+1; j < size; j++)
if (a[j] < a[i])
Swap(a[j],a[i]);
}
// deal n cards from deck d
void DealHand(CardDeck& d, int n)
{
int cards[52];
// deal n cards and record them in array cards
for(int i=0;i < n;i++)
cards[i] = d.GetCard();
// sort the card values
Sort(cards,n);
// print the card faces
for(i=0;i < n;i++)
d.PrintCard(cards[i]);
}
void main(void)
{
CardDeck d;
// deck is shuffled. deal a hand
DealHand(d,5);
cout << endl << endl;
// shuffle again and deal
d.Shuffle();
DealHand(d,5);
}
/*
<Run>
6 of clubs
6 of diamonds
10 of diamonds
5 of hearts
Queen of hearts
King of clubs
3 of diamonds
King of diamonds
10 of hearts
Ace of spades
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -