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
| #include #include using namespace std;
int main() { int iacnt[4][13] = {0}; int a, j, k; int ia[4][13] = { {101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113}, {201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213}, {301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313}, {401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413} }; int player[4][13]; for (int jcnt = 0; jcnt <4; ++jcnt) { for (int kcnt = 0; kcnt <13; ++kcnt) { soso: a = rand(); j = a % 4; k = a % 13; if (iacnt[j][k] == 1) goto soso; // 避免重复发牌 player[jcnt][kcnt] = ia[j][k]; iacnt[j][k] = 1; } } for (int m = 0; m <4; ++m) { for (int n = 0; n <13; ++n) { cout < } cout < } system("pause"); return 0; } |