鬥地主發牌

2021-08-13 18:22:43 字數 2139 閱讀 2854

鬥地主的發牌

a:鬥地主的發牌

/** 實現模擬鬥地主的功能

* 1. 組合牌

* 2. 洗牌

* 3. 發牌

* 4. 看牌

*/public class doudizhu ;

//定義4個花色陣列

string colors = ;

//定義整數變數,作為鍵出現

int index = 2;

//遍歷陣列,花色+點數的組合,儲存到map集合

for(string number : numbers)

}//儲存大王,和小王

pooker.put(0, "大王");

pookernumber.add(0);

pooker.put(1, "小王");

pookernumber.add(1);

//洗牌,將牌的編號打亂

collections.shuffle(pookernumber);

//發牌功能,將牌編號,發給玩家集合,底牌集合

arraylistplayer1 = new arraylist();

arraylistplayer2 = new arraylist();

arraylistplayer3 = new arraylist();

arraylistbottom = new arraylist();

//發牌採用的是集合索引%3

for(int i = 0 ; i < pookernumber.size() ; i++)else if(i % 3 == 0)else if( i % 3 == 1)else if( i % 3 == 2)}}

}###21鬥地主的看牌

a:鬥地主的看牌

/** 實現模擬鬥地主的功能

* 1. 組合牌

* 2. 洗牌

* 3. 發牌

* 4. 看牌

*/public class doudizhu ;

//定義4個花色陣列

string colors = ;

//定義整數變數,作為鍵出現

int index = 2;

//遍歷陣列,花色+點數的組合,儲存到map集合

for(string number : numbers)

}//儲存大王,和小王

pooker.put(0, "大王");

pookernumber.add(0);

pooker.put(1, "小王");

pookernumber.add(1);

//洗牌,將牌的編號打亂

collections.shuffle(pookernumber);

//發牌功能,將牌編號,發給玩家集合,底牌集合

arraylistplayer1 = new arraylist();

arraylistplayer2 = new arraylist();

arraylistplayer3 = new arraylist();

arraylistbottom = new arraylist();

//發牌採用的是集合索引%3

for(int i = 0 ; i < pookernumber.size() ; i++)else if(i % 3 == 0)else if( i % 3 == 1)else if( i % 3 == 2)

}//對玩家手中的編號排序

collections.sort(player1);

collections.sort(player2);

collections.sort(player3);

//看牌,將玩家手中的編號,到map集合中查詢,根據鍵找值

//定義方法實現

look("劉德華",player1,pooker);

look("張曼玉",player2,pooker);

look("林青霞",player3,pooker);

look("底牌",bottom,pooker);

}public static void look(string name,arraylistplayer,hashmappooker)

system.out.println();

}}

Python 鬥地主發牌程式

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

C語言 鬥地主發牌程式

題目 仍然是小學期,就當娛樂 貼 include include include 函式宣告 void sortcards int int void showcards int int void changecard int int getonecard int cards 55 用於記錄每張牌是否被...

Java實現鬥地主發牌過程

public class poker 加入大小王 map.put index 小王 map.put index 大王 一副54張的牌 arraylist裡邊為0 53的數的新牌 listcards new arraylist for int i 0 i 53 i 洗牌 collections.shu...