程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 劣質代碼評析——《寫給大家看的C語言書(第2版)》附錄B之21點程序(四)

劣質代碼評析——《寫給大家看的C語言書(第2版)》附錄B之21點程序(四)

編輯:關於C語言

View Code

.    .     cards[],playerPoints[],dealerPoints[],total[.    .     
.       initCardsScreen(cards,playerPoints,dealerPoints,total, &.       dealerGetsCard(&.       printf(.       playerGetsCard(&.       playerGetsCard(&.       
.          ans = getAns(.           ( ans == .             playerGetsCard(&.       ( ans != .       
.          dealerGetsCard(&.        (dealerPoints[ACEHIGH] < .       ans = getAns(.    (ans==.     . }

   .       dealerGetsCard(&numCards,cards, dealerPoints);

    

    .  dealerGetsCard( *numCards, cards[.  dealerPoints[]);

    

    void dealerGetsCard ( int *numCards , int cards[] , int dealerPoints[] );

 

    .  dealerGetsCard( *numCards, cards[], dealerPoints[.    .    newCard =.    printf(. }

   

 

     dealerGetsCard( *numCards, cards[],

   

    .  dealCard( * numCards, cards[.  dealCard( * numCards, cards[.    .    srand(time(&.    subDraw = (rand()%(*numCards));    
    .    cardDrawn =.    cards[subDraw] = cards[*numCards -.    (*numCards)--.    . }

   

 

    .    time_t t;

    

    .    srand(time(&t));

   

    srand( time ( NULL ) );

 

    int main(void)
    {
       /*……*/
    
       do{
            srand( time ( NULL ) );
            /*21點游戲*/
        }
       while( getAns("\nPlay again(Y/N)?") == 'Y' );  /*詢問是否繼續*/
    
        return 0;
    }

   .    subDraw = ( rand() % (*numCards) );    

   

    dispCard ( dealCard( numCards , cards ) , dealerPoints ) ;
    //原115.    dispCard(newCard,dealerPoints);

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved