게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
이 오류가 왜나오나염..
게시물ID : programmer_10988짧은주소 복사하기
작성자 : Shyarulote
추천 : 0
조회수 : 283회
댓글수 : 2개
등록시간 : 2015/06/07 22:50:35
error.jpg


크앙....

밑에는 저 main... (원래 나눠해야 한다는 거 알아요...)

#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <algorithm>
#include <string>


using namespace std;

int main()
{
    int gameresult[7]={0,0,0,0,0,0,0}; //1-블랙잭 2-가위바위보
    int gameswitch[7]={0,0,0,0,0,0,0};
    int inputgame;
    int play;
    int temp;


    do{
    system("cls");
    cout  << "당신의 승점" << gameresult[0] << ", "<< gameresult[1] << ", "<< gameresult[2] << ", "<< gameresult[3] << ", "<< gameresult[4] << ", "<< gameresult[5] << ", "<< gameresult[6] << endl << "게임을 선택하세요. (1.블랙잭 2.가위바위보 3.로또 6/45 4. 5. 6. 7.)" << endl;

    cin >> inputgame;

    if (inputgame == 1){
        temp=blackjack();
        if (temp==1){
            gameresult[0]+=temp;
        }
        else if (temp==2){
            gameresult[0]+=temp;
        }
        else {
            gameresult[0]+=-1;
        }
    }
    else if (inputgame == 2){
        if (temp==1){
            gameresult[1]+=temp;
        }
        else if (temp==2){
            gameresult[1]+=temp;
        }
        else {
            gameresult[1]+=-1;
        }
    }
    else if (inputgame == 3){
        if (temp==1){
            gameresult[2]+=temp;
        }
        else if (temp==2){
            gameresult[2]+=temp;
        }
        else {
            gameresult[2]+=-1;
        }
    }
    else {
        cout << "잘못된 입력입니다." << endl;
    }

    cout << "게임하시겠습니까? (1.Yes 2.No)" << endl;
    cin >> play;
    }while (play == 1);

    return 0;
}

int blackjack(){
    string card[]={"Ace","2","3","4","5","6","7","8","9","10","King","Queen","Jack"};
    int cardselect;
    int i;
    int Playerresult=0;
    int Computerresult=0;
    int c=2;
    int d=2;
    string Playercard[5];
    int Player[5]={0,0,0,0,0};
    int Computer[5]={0,0,0,0,0};
    string Computercard[5];

    cout << "카드는 최대 5장까지 뽑을 수 있습니다." << endl << "비길 경우 패배처리 됩니다." << endl << "=============================" << endl << endl;

    random_shuffle(card,card+13);
    Playercard[0]=card[0];
    random_shuffle(card,card+13);
    Playercard[1]=card[0];
    random_shuffle(card,card+13);
    Computercard[0]=card[0];
    random_shuffle(card,card+13);
    Computercard[1]=card[0];

    cout << "Player의 현재 카드 : " << Playercard[0] << ", " << Playercard[1] << endl;
    cout << "Computer의 현재 카드 : " << Computercard[0] << ", " << Computercard[1] << endl << endl;
    cout << "카드를 더 뽑으시겠습니까? (1.Yes 2.No)";
    cin >> cardselect;
            for(i=0;i<5;i++){
                if(Computercard[i]=="2"){
                    Computer[i]=2;
                }
                else if(Computercard[i]=="3"){
                    Computer[i]=3;
                }
                else if(Computercard[i]=="4"){
                    Computer[i]=4;
                }
                else if(Computercard[i]=="5"){
                    Computer[i]=5;
                }
                else if(Computercard[i]=="6"){
                    Computer[i]=6;
                }
                else if(Computercard[i]=="7"){
                    Computer[i]=7;
                }
                else if(Computercard[i]=="8"){
                    Computer[i]=8;
                }
                else if(Computercard[i]=="9"){
                    Computer[i]=9;
                }
                else if(Computercard[i]=="10"){
                    Computer[i]=10;
                }
                else if(Computercard[i]=="Jack"){
                    Computer[i]=10;
                }
                else if(Computercard[i]=="Queen"){
                    Computer[i]=10;
                }
                else if(Computercard[i]=="King"){
                    Computer[i]=10;
                }
        }

        for(i=0;i<5;i++){
            Computerresult+=Computer[i];
        }
        for(i=0;i<5;i++){
            if(Computercard[i]=="Ace" && Computerresult <= 10){
                Computer[i]=11;
                Computerresult+=Computer[i];
            }
            else{
                Computer[i]=1;
                Computerresult+=Computer[i];
            }
        }
        while (Computerresult <= 15 && c < 5){
            random_shuffle(card,card+13);
            Computercard[c]=card[0];
            c++;
        }

    if (cardselect == 1){
        while (cardselect ==1){
            random_shuffle(card,card+13);
            Playercard[d]=card[0];
            cout << "뽑은 카드 -> " << Playercard[d] << endl << "=============================" << endl ;
            d++;
            cout << "카드를 더 뽑으시겠습니까? (1.Yes 2.No)";
            cin >> cardselect;
        }
    }
    else if (cardselect == 2){
            for(i=0; i<d; i++){
                if (Playercard[i] == "Ace"){
                cout << "Ace를 1과 11 중 무엇으로 사용하시겠습니까?";
                cin >> Player[i];
                }
            }

        for(i=0;i<d;i++){
            if(Playercard[i]=="2"){
                Player[i]=2;
            }
            else if(Playercard[i]=="3"){
                Player[i]=3;
            }
            else if(Playercard[i]=="4"){
                Player[i]=4;
            }
            else if(Playercard[i]=="5"){
                Player[i]=5;
            }
            else if(Playercard[i]=="6"){
                Player[i]=6;
            }
            else if(Playercard[i]=="7"){
                Player[i]=7;
            }
            else if(Playercard[i]=="8"){
                Player[i]=8;
            }
            else if(Playercard[i]=="9"){
                Player[i]=9;
            }
            else if(Playercard[i]=="10"){
                Player[i]=10;
            }
            else if(Playercard[i]=="Jack"){
                Player[i]=10;
            }
            else if(Playercard[i]=="Queen"){
                Player[i]=10;
            }
            else if(Playercard[i]=="King"){
                Player[i]=10;
            }
        }
        for(i=0;i<d;i++){
            Playerresult+=Player[i];
        }
    }

    cout << "=============================" << endl << "게임 결과" << endl << "컴퓨터의 점수 : " << Computerresult << endl;
    cout << "당신의 점수 : " << Playerresult << endl << "=============================" << endl;

    if (Playerresult > 21 && Computerresult <= 21){
        cout << "인간의 욕심은 끝이 없다. 당신은 잘못된 선택으로 패배하였습니다." << endl;
        return 3;
    }
    else if (Computerresult > Playerresult && Computerresult <= 21){
        cout << "당신은 컴퓨터에게 운으로 패배하셨습니다." << endl;
        return 3;
    }
    else if (Playerresult == 21){
        cout << "Black Jack!" << endl;
        return 2;
    }
    else if (Playerresult < Computerresult){
        cout << "당신은 컴퓨터에게 승리하셨습니다." << endl;
        return 1;
    }
    else{
        cout << "당신은 어쨌든 졌습니다." << endl;
        return 3;
    }
}

int rsp(){

} //아직 미구현

int lotto(){

} //아직 미구현
꼬릿말 보기
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호