- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
void change_card( int array_suit[] , int array_face[] , int deck[][13] ) {
int r = 0;
void change_count( int *array_suit, int *array_face , int array_deck[][13], int count);
static int y = 11;
while( r != 5) {
if(array_face[r] == -1 ) {
y++;
change_count( &array_suit[r], &array_face[r], deck, y);
}
r++;
}
}
void change_count(int *array_suit, int *array_face , int array_deck[][13], int count) {
int row = 0 , column = 0;
for( row = 0 ; row <= 3; row++) {
for( column = 0 ; column <= 12 ; column++) {
if(array_deck[row][column] == count ) {
*array_suit = row;
*array_face = column;
break;
}
}
}
}
int sort_select(int arr[], int arr_2[] , int p, int up_turn) {
void swap(int *elementptr1, int *elementptr2);
int search(int st[], int s, int choice, int up_turn);
int min;
if (p == MAX ) {
return 1;
} else {
min = search(arr, p, p, up_turn);
swap(&arr_2[p], &arr_2[min]);
swap(&arr[p], &arr[min]);
}
return sort_select(arr, arr_2, p + 1, up_turn);
}
int search(int st[], int s, int choice, int turn) {
int p;
if (turn == 1) {
p = MAX ;
} else if (turn == 2) {
p = 5;
}
if (s < p) {
if (turn == 1) {
if (st[s] > st[choice]) {
choice = s;
}
} else if (turn == 2) {
if (st[s] < st[choice])
choice = s;
}
return search(st, s + 1, choice, turn);
} else {
return choice;
}
}
void shuffle(int wDeck[][13]) {
int row = 0, column = 0, card, tmp = 0, tmp_1 = 0, tmp_2 = 0;
void swap(int *elementptr1, int *elementptr2);
for (card = 1; card < 52; card++) {
tmp_1 = rand() % 3;
tmp_2 = rand() % 12;
for (row = 0; row <= 3; row++) {
for (column = 0; column <= 12; column++) {
if (wDeck[row][column] == card) {
swap(&wDeck[row][column], &wDeck[tmp_1][tmp_2]);
}
}
}
}
}
void combi(int wDeck[][13]) {
int row , column,card = 1;
for (row = 0; row <= 3; row++) {
for (column = 0; column <= 12; column++) {
wDeck[row][column] = card; card++;
}
}
}
void deal(int wDeck[][13], int gm_suit[], int gm_face[], int mg_suit[], int mg_face[]) {
int card = 1, row, column, y = 0, x = 0;
while (card++ <= 10) {
for (row = 0; row <= 3; row++) {
for (column = 0; column <= 12; column++) {
if (wDeck[row][column] == card) {
if (0 == card % 2) {
gm_suit[y] = row; gm_face[y] = column; y++; break;
} else {
mg_suit[x] = row; mg_face[x] = column; x++; break;
}
}
}
}
}
}
Комментарии (0) RSS
Добавить комментарий