BRONZE
BRONZE 등급의 판매자 자료

Five-card poker game

[문제해석] Modify the program in Figs. 8.25–-8.27 of C++ How to Program: Fifth Edition so that the card-dealing function deals a five-card poker hand. Then write functions to accomplish each of the following tasks: a) Determine if the hand contains a pair. b) Determine if the hand contains two pairs. c) Determine if the hand contains three of a kind (e.g., three jacks). d) Determine if the hand contains four of a kind (e.g., four aces). e) Determine if the hand contains a flush (i.e., all five cards of the same suit). f) Determine if the hand contains a straight (i.e., five cards of consecutive face values). Hints: � .�. Allow class DeckOfCards to store a 5 card hand in a 5-by-2 array (five ranks and five suits). Implement the functions as member functions of class DeckOfCards. �.�. To determine if two (or more) cards are of the same rank, create an array of 13 elements—-one for each rank—-and initialize its elements to 0. Iterate through the hand, incrementing the appropriate rank within your array. Finally, loop through the resulting array, checking for elements greater than or equal to 2 (or 3 or 4). �.�. Similarly, check for a flush by creating a four-element array, where each element represents a different suit. �.�. Check for a straight by using the insertion sort.
10 페이지
한컴오피스
최초등록일 2010.01.15 최종저작일 2006.06
10P 미리보기
Five-card poker game
  • 미리보기

    소개

    [문제해석]

    Modify the program in Figs. 8.25–-8.27 of C++ How to Program: Fifth Edition so that the card-dealing function deals a
    five-card poker hand. Then write functions to accomplish each of the following tasks:
    a) Determine if the hand contains a pair.
    b) Determine if the hand contains two pairs.
    c) Determine if the hand contains three of a kind (e.g., three jacks).
    d) Determine if the hand contains four of a kind (e.g., four aces).
    e) Determine if the hand contains a flush (i.e., all five cards of the same suit).
    f) Determine if the hand contains a straight (i.e., five cards of consecutive face values).
    Hints:

    .�. Allow class DeckOfCards to store a 5 card hand in a 5-by-2 array (five ranks and five suits). Implement the functions as member functions of class DeckOfCards.
    �.�. To determine if two (or more) cards are of the same rank, create an array of 13 elements—-one for each rank—-and initialize its elements to 0. Iterate through the hand, incrementing the appropriate rank within your array. Finally, loop through the resulting array, checking for elements greater than or equal to 2 (or 3 or 4).
    �.�. Similarly, check for a flush by creating a four-element array, where each element represents a different suit.
    �.�. Check for a straight by using the insertion sort.

    목차

    1.문제해석
    2. 알고리즘
    3. 입력과 출력의 정의
    4.주석과 소스

    본문내용

    2. 알고리즘

    - DeckOfCards 클래스 지정
    - 모양 4개, 숫자 13가지의 총 52장의 카드를 섞는다
    - 그 중 다섯 장을 임의로 뽑아 배열 hand[][]에 저장한다.
    - 뽑힌 카드를 출력
    - 카드의 같은 숫자의 개수, 같은 모양의 개수에 따른 결과값을 출력한다.

    3. 입력과 출력의 정의

    - 입력 : 없음

    - 출력 : 선택 된 카드가 저장되어 있는 배열, 숫자, 모양

    4.주석과 소스

    <<soa.cpp>>
    #include<iostream>
    #include<iomanip>
    #include<cstdlib>
    #include<ctime>
    using namespace std;
    #include "soa.h"

    DeckOfCards::DeckOfCards()// 배열을 초기화 시킨다.
    {
    for(int row=0; row<=3; row++)// 4개의 모양 배열
    {
    for(int column = 0; column<=12; column++)// 13개의 숫자 배열
    {
    deck[row][column]=0;// 모양 * 숫자 배열을 `0`으로 초기화 시킨다.
    }
    }
    }

    void DeckOfCards::shuffle()// 카드 섞는 함수
    {
    int row;// 변수 row에 열을 지정
    int column;// 변수 colum에 행을 지정
    srand((unsigned)time(NULL));// 난수 발생

    for(int card=1; card<=52; card++)// 52장의 카드생성
    {
    do
    {
    row=rand()%4;// row에는 4가지 경우 지정
    column = rand()%13;// colum에는 13가지의 경우 지정
    }while(deck[row][column]!=0);//배열 deck[row][column]!=0일 경우 실행

    참고자료

    · 없음
  • 자료후기

    Ai 리뷰
    지식판매자가 등록한 자료는 내용이 풍부하고 깊이 있는 분석이 돋보입니다. 과제에 바로 활용할 수 있는 내용이 많아 매우 만족합니다. 감사드립니다.
    왼쪽 화살표
    오른쪽 화살표
  • 자주묻는질문의 답변을 확인해 주세요

    해피캠퍼스 FAQ 더보기

    꼭 알아주세요

    • 자료의 정보 및 내용의 진실성에 대하여 해피캠퍼스는 보증하지 않으며, 해당 정보 및 게시물 저작권과 기타 법적 책임은 자료 등록자에게 있습니다.
      자료 및 게시물 내용의 불법적 이용, 무단 전재∙배포는 금지되어 있습니다.
      저작권침해, 명예훼손 등 분쟁 요소 발견 시 고객센터의 저작권침해 신고센터를 이용해 주시기 바랍니다.
    • 해피캠퍼스는 구매자와 판매자 모두가 만족하는 서비스가 되도록 노력하고 있으며, 아래의 4가지 자료환불 조건을 꼭 확인해주시기 바랍니다.
      파일오류 중복자료 저작권 없음 설명과 실제 내용 불일치
      파일의 다운로드가 제대로 되지 않거나 파일형식에 맞는 프로그램으로 정상 작동하지 않는 경우 다른 자료와 70% 이상 내용이 일치하는 경우 (중복임을 확인할 수 있는 근거 필요함) 인터넷의 다른 사이트, 연구기관, 학교, 서적 등의 자료를 도용한 경우 자료의 설명과 실제 자료의 내용이 일치하지 않는 경우

함께 구매한 자료도 확인해 보세요!

찾으시던 자료가 아닌가요?

지금 보는 자료와 연관되어 있어요!
왼쪽 화살표
오른쪽 화살표
문서 초안을 생성해주는 EasyAI
안녕하세요. 해피캠퍼스의 방대한 자료 중에서 선별하여 당신만의 초안을 만들어주는 EasyAI 입니다.
저는 아래와 같이 작업을 도와드립니다.
- 주제만 입력하면 목차부터 본문내용까지 자동 생성해 드립니다.
- 장문의 콘텐츠를 쉽고 빠르게 작성해 드립니다.
- 스토어에서 무료 캐시를 계정별로 1회 발급 받을 수 있습니다. 지금 바로 체험해 보세요!
이런 주제들을 입력해 보세요.
- 유아에게 적합한 문학작품의 기준과 특성
- 한국인의 가치관 중에서 정신적 가치관을 이루는 것들을 문화적 문법으로 정리하고, 현대한국사회에서 일어나는 사건과 사고를 비교하여 자신의 의견으로 기술하세요
- 작별인사 독후감
해캠 AI 챗봇과 대화하기
챗봇으로 간편하게 상담해보세요.
2025년 05월 21일 수요일
AI 챗봇
안녕하세요. 해피캠퍼스 AI 챗봇입니다. 무엇이 궁금하신가요?
7:54 오후