C語言 鬥地主發牌程式

2021-08-05 18:23:53 字數 1572 閱讀 6805

題目**仍然是小學期,就當娛樂

貼**:

#include

#include

#include

//函式宣告

void sortcards(int *, int);

void showcards(int *, int);

void changecard(int);

int getonecard();

int cards[55] = ;//用於記錄每張牌是否被用過( 丟棄cards[0]

int main() //rand()%m+1,產生0- m-1的隨機數

; int player_b[18] = ;

int player_c[18] = ;

int ground[4] = ;//abandon all [0]

for (i = 1; i <= 3; i++)//獲取底牌

sortcards(ground, 4);//按牌大小排序

for (i = 1; i <= 17; i++)//為三個玩家分別發牌

puts("player's cards");

sortcards(player_a, 18);

sortcards(player_b, 18);

sortcards(player_c, 18);

puts("player_a:");//列印a的牌

showcards(player_a, 17);

puts("\n\nplayer_b:");//列印b的牌

showcards(player_b, 17);

puts("\n\nplayer_c:");//列印c的牌

showcards(player_c, 17);

puts("\n\ncards on the ground:");

showcards(ground, 3);//列印底牌

puts("");

system("pause");

return0;}

int getonecard()//通過隨機數取得一張沒用過的牌

cards[irandnum] = 1;

return irandnum;

}void showcards(int *player, int count)//列印玩家的牌

else

if (player[i] == 54)

else

if (player[i] % 4 == 0)

else

if ((player[i] + 1) % 4 == 0)

else

if (player[i] % 2 == 0)

else

}}void changecard(int card)//將數字和紙牌進行對換

}void sortcards(int *nums, int length)//排序手中的牌}}

}

程式有錯麻煩告訴我^_^

鬥地主發牌

鬥地主的發牌 a 鬥地主的發牌 實現模擬鬥地主的功能 1.組合牌 2.洗牌 3.發牌 4.看牌 public class doudizhu 定義4個花色陣列 string colors 定義整數變數,作為鍵出現 int index 2 遍歷陣列,花色 點數的組合,儲存到map集合 for strin...

Python 鬥地主發牌程式

1 1副牌 52 2 54張 2 有大小王,用提供的國王和皇后的符號表示大小王 3 54張牌發給3個玩家,每人17張牌,並有3張底牌。4 輸出3個玩家的牌,按照由小到大,黑紅梅方的順序。5 輸出3張底牌 5 輸出每個玩家有幾個炸彈 4張面值一樣的牌,或者大小王在一起,為乙個炸彈。注 鬥地主發牌程式 ...

C語言 鬥地主洗牌發牌以及叫 搶地主

本程式包含了鬥地主小遊戲以下幾個部分 1.打亂牌堆的54張牌所對應的54個數字 1 54 2.發牌 3.排序 4.數字與牌型的轉換 5.3位玩家叫地主及搶地主機制的實現 6.特殊情況 3位玩家均不叫地主情況的解決 include include include inttrans int n int ...