#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void shuffle(int[][13]);
void print_trump(int[][13]);
void random(int[]);
void trade(int[][13], int[]);
int main() {
int deck[4][13];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
deck[i][j] = ((i + 1) * 1000) + j + 1;
}
}
shuffle(deck);
int count = 1;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 13; j++) {
printf("%2d: %d-%2d\n", count
, (deck
[i
][j
] / 1000) * 100, deck[i][j] % 100);
count++;
}
}
}
void shuffle(int array[][13]) {
int r_array[4];
for (int i = 0; i < 100; i++) {
random(r_array);
trade(array, r_array);
}
}
void random(int r_array[]) {
r_array
[0] = rand() % 13; r_array
[1] = rand() % 13;}
void trade(int array[][13], int r_array[]) {
int tmp = array[r_array[2]][r_array[0]];
array[r_array[2]][r_array[0]] = array[r_array[3]][r_array[1]];
array[r_array[3]][r_array[1]] = tmp;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KIAp2b2lkIHNodWZmbGUoaW50W11bMTNdKTsKdm9pZCBwcmludF90cnVtcChpbnRbXVsxM10pOwp2b2lkIHJhbmRvbShpbnRbXSk7CnZvaWQgdHJhZGUoaW50W11bMTNdLCBpbnRbXSk7CiAKaW50IG1haW4oKSB7CiAgICBzcmFuZCh0aW1lKE5VTEwpKTsKICAgIGludCBkZWNrWzRdWzEzXTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgNDsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCAxMzsgaisrKSB7CiAgICAgICAgICAgIGRlY2tbaV1bal0gPSAoKGkgKyAxKSAqIDEwMDApICsgaiArIDE7CiAgICAgICAgfQogICAgfQogICAgc2h1ZmZsZShkZWNrKTsKICAgIGludCBjb3VudCA9IDE7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDQ7IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgMTM7IGorKykgewogICAgICAgICAgICBwcmludGYoIiUyZDogJWQtJTJkXG4iLCBjb3VudCwgKGRlY2tbaV1bal0gLyAxMDAwKSAqIDEwMCwKICAgICAgICAgICAgICAgICAgIGRlY2tbaV1bal0gJSAxMDApOwogICAgICAgICAgICBjb3VudCsrOwogICAgICAgIH0KICAgIH0KfQogCnZvaWQgc2h1ZmZsZShpbnQgYXJyYXlbXVsxM10pIHsKICAgIGludCByX2FycmF5WzRdOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCAxMDA7IGkrKykgewogICAgICAgIHJhbmRvbShyX2FycmF5KTsKICAgICAgICB0cmFkZShhcnJheSwgcl9hcnJheSk7CiAgICB9Cn0KIAp2b2lkIHJhbmRvbShpbnQgcl9hcnJheVtdKSB7CiAgICByX2FycmF5WzBdID0gcmFuZCgpICUgMTM7CiAgICByX2FycmF5WzFdID0gcmFuZCgpICUgMTM7CiAgICByX2FycmF5WzJdID0gcmFuZCgpICUgNDsKICAgIHJfYXJyYXlbM10gPSByYW5kKCkgJSA0Owp9CiAKdm9pZCB0cmFkZShpbnQgYXJyYXlbXVsxM10sIGludCByX2FycmF5W10pIHsKICAgIGludCB0bXAgPSBhcnJheVtyX2FycmF5WzJdXVtyX2FycmF5WzBdXTsKICAgIGFycmF5W3JfYXJyYXlbMl1dW3JfYXJyYXlbMF1dID0gYXJyYXlbcl9hcnJheVszXV1bcl9hcnJheVsxXV07CiAgICBhcnJheVtyX2FycmF5WzNdXVtyX2FycmF5WzFdXSA9IHRtcDsKfQo=