本篇文章為大家展示了使用C語言編寫一個洗牌與發(fā)牌游戲,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
在坪山等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作定制網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),成都營銷網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站建設(shè)公司,坪山網(wǎng)站建設(shè)費用合理。普通版
#include#include #include #define SUITS 4 #define FACES 13 #define CARDS 52 void shuffle(int wDeck[][FACES]); void send(int wDeck[][FACES], const char* wSuit[], const char* wFace[]); void main() { int deck[SUITS][FACES]={0}; const char* suit[SUITS]={"Heart","Diamond","Club","Spade"}; const char* face[FACES]={"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"}; srand(time(NULL)); shuffle(deck); send(deck, suit, face); } void shuffle(int wDeck[][FACES]) { int row,column,card; for(card=1;card<=CARDS;card++) { row = rand() % SUITS; column = rand() % FACES; while(wDeck[row][column] != 0) { row = rand() % SUITS; column = rand() % FACES; } wDeck[row][column] = card; } } void send(int wDeck[][FACES], const char* wSuit[], const char* wFace[]) { int card,row,column; for(card=1;card<=CARDS;card++) { for(row=0;row 高性能版
//先按順序填滿52個格子,再產(chǎn)生隨機(jī)格子相互交換 #include#include #include #define CARDS 52 #define FACES 13 struct card { const char* face; const char* suit; }; typedef struct card Card; void shuffle(Card *const wDeck); void send(const Card *const wDeck);//指針常量與數(shù)據(jù)常量均不可以改變,都用const限定,*前是限定指針,*后是限定數(shù)據(jù) void main() { const char* wSuit[]={"Heart","Diamond","Club","Spade"};//指針數(shù)組是一個數(shù)組 const char* wFace[]={"Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"}; int i; Card deck[CARDS]; for(i=0;i 上述內(nèi)容就是使用C語言編寫一個洗牌與發(fā)牌游戲,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
新聞標(biāo)題:使用C語言編寫一個洗牌與發(fā)牌游戲-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://weahome.cn/article/jojsh.html