Turbo-C
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
터보-C 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
Lua 게시판
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C/C++ Q/A
[2747] 카드게임이라는데요..
C++초짜-_-; [] 1246 읽음    2003-06-10 01:45
카드 게임이라는데요..-_-;
밑에 주석으로 설명되어 있는 함수를 짜는거같아요.ㅠ_ㅠ..
저희반애들이 아무도 못해서리.. 이렇게 올리게됬어요'ㅁ';
좀 도와주실수 있음..ㅠ_ㅠ...
부탁드립니다..
오늘까지라서.ㅠ_ㅠ..






#include <iostream>
#include <stdlib.h>

using std::cout;
using std::ios;

#include <iomanip>

using std::setw;
using std::setprecision;
using std::setiosflags;
using std::resetiosflags;

#include <cstdlib>
#include <ctime>

void shuffle( int [][ 13 ] );
void deal( const int [][ 13 ], const char *[], const char *[], int [][ 2 ] );
void pair( const int [][ 13 ], const int [][ 2 ], const char *[] );
void threeOfKind( const int [][ 13 ], const int [][ 2 ], const char *[] );
void fourOfKind( const int [][ 13 ], const int [][ 2 ], const char *[] );
void flushHand( const int [][ 13 ], const int [][ 2 ], const char *[] );
void straightHand( const int [][ 13 ], const int [][ 2 ], const char *[],
                  const char *[] );

int main()
{
   const char *suit[] = { "Hearts", "Diamonds", "Clubs", "Spades" },
              *face[] = { "Ace", "2", "3", "4", "5", "6",
                          "7", "8", "9", "10", "Jack", "Queen",
                          "King" };
   int deck[ 4 ][ 13 ] = { 0 }, hand[ 7 ][ 2 ] = { 0 };

   srand( time( 0 ) );

   shuffle( deck );
   deal( deck, face, suit, hand );
   pair( deck, hand, face );
   threeOfKind( deck, hand, face );
   fourOfKind( deck, hand, face );
   flushHand( deck, hand, suit );
   straightHand( deck, hand, suit, face );

   system("PAUSE");
   return 0;
}

void shuffle( int wDeck[][ 13 ] )
{
   int row, column;

   for ( int card = 1; card <= 52; ++card ) {
      do {
        row = rand() % 4;
        column = rand() % 13;
      } while ( wDeck[ row ][ column ] != 0 );

      wDeck[ row ][ column ] = card;
   }
}

// deal a five card poker hand
void deal( const int wDeck[][ 13 ], const char *wFace[],
          const char *wSuit[], int wHand[][ 2 ] )
{
   int r = 0;

   cout << "The hand is:\n";

   for ( int card = 1; card < 8; ++card )
      for ( int row = 0; row <= 3; ++row )
         for ( int column = 0; column <= 12; ++column )
            if ( wDeck[ row ][ column ] == card ) {
               wHand[ r ][ 0 ] = row;
               wHand[ r ][ 1 ] = column;
               cout << setw( 5 ) << wFace[ column ]
                    << " of " << setw( 8 ) << setiosflags( ios::left )
                    << wSuit[ row ] << ( card % 2 == 0 ? '\n' : '\t' )
                    << resetiosflags( ios::left );
               ++r;
            }

   cout << '\n';
}


void pair( const int wDeck[][ 13 ], const int wHand[][ 2 ],
           const char *wFace[] )
{
// wHand의 값 중 2 개의 숫자가 같은 카드의 갯수와 종류를 출력함

}

void threeOfKind( const int wDeck[][ 13 ], const int wHand[][ 2 ],
                 const char *wFace[] )
{
// wHand의 값 중 3 개의 숫자가 같은 카드의  갯수와 종류를 출력함

}

void fourOfKind( const int wDeck[][ 13 ], const int wHand[][ 2 ],
                const char *wFace[] )
{
// wHand의 값 중 4 개의 숫자가 같은 카드의 갯수와 종류를 출력함

}

void flushHand( const int wDeck[][ 13 ], const int wHand[][ 2 ],
               const char *wSuit[] )
{
// 같은 무늬 (suit)가 다섯장 일 경우 무늬의 종류를 출력함
}

void straightHand( const int wDeck[][ 13 ], const int wHand[][ 2 ],
                  const char *wSuit[], const char *wFace[] )
{
// 1~ King 까지의 숫자 중 연속된 5개의 숫자가 있을 경우 시작 숫자를 출력함

}

+ -

관련 글 리스트
2747 카드게임이라는데요.. C++초짜-_-; 1246 2003/06/10
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.