-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSortOps.cpp
More file actions
76 lines (70 loc) · 1.18 KB
/
Copy pathSortOps.cpp
File metadata and controls
76 lines (70 loc) · 1.18 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "Common.h"
#include "SortOps.h"
PDILowerCompare g_pdi_lower_compare;
PIILowerCompare g_pii_lower_compare;
PDSHigherCompare g_pds_higher_compare;
PFUILowerCompare g_pfui_lower_compare;
void SortCards(Card *cards, unsigned int n)
{
if (n == 1)
{
return;
}
else if (n == 2)
{
if (cards[0] < cards[1])
{
Card temp = cards[0];
cards[0] = cards[1];
cards[1] = temp;
}
}
else if (n == 3)
{
Card c0 = cards[0];
Card c1 = cards[1];
Card c2 = cards[2];
if (c0 > c1)
{
if (c1 > c2)
{
}
else if (c0 > c2)
{
cards[1] = c2;
cards[2] = c1;
}
else
{
cards[0] = c2;
cards[1] = c0;
cards[2] = c1;
}
}
else
{
if (c0 > c2)
{
cards[0] = c1;
cards[1] = c0;
}
else if (c1 > c2)
{
cards[0] = c1;
cards[1] = c2;
cards[2] = c0;
}
else
{
cards[0] = c2;
cards[1] = c1;
cards[2] = c0;
}
}
}
else
{
fprintf(stderr, "Don't know how to sort %u cards\n", n);
exit(-1);
}
}