게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
장글 질문입니다. C++ 프로그램에 대해서 질문 있습니다
게시물ID : it_7158짧은주소 복사하기
작성자 : 초급인
추천 : 0
조회수 : 1341회
댓글수 : 1개
등록시간 : 2020/03/26 06:26:59
옵션
  • 본인삭제금지
학교 숙제로 게임 프로그램을 만들어야 하는데요.

게임 룰이
주사위를 던지면 (1에서 6까지)
1은 머리고 (1개)
2은 몸 (1개)
3은 날개 (6개를 모아야 합니다. 그러니까 3이 6번 나와아 합니다.)
4는 다리 (똑같이 6개)
5는 눈 (2개)
6은 꼬리 (1개)
컴푸터랑 계속 주사위를 던져서 어는 쪽이 먼저 모두 모은 다면 끝나는 게임 입니다.

질문은요.
일단
게임 시작하시겠습니까?
라고 하면 Y 누르고
그 다음에

Roll (y/n)
던진다

플레이어 숫자 = 2
컴터 숫자 = 1

플레이어 가 몸통을 얻었습니다.

Roll(y/n)
던진다.

플레이어 숫자 = 1
컴터 숫자 = 2
컴터가 몸통을 얻었습니다.
플레이어가 머리를 얻었습니다.

그런 방법으로
총 합계가 6이 되면 승리 하는 것으로 하고 싶은데...


loop 어찌 해야 하는지 감이 안 잡히네요..
조언 좀 부탁드려요.

#include<iostream>
#include<ctime>
using namespace std;

int main() {

    srand(time(NULL));
    const int body  = 1;
    const int Head  = 2;
    const int Wings = 3;
    const int Legs  = 4;
    const int Eyes  = 5;
    const int tail  = 6;
    
    int player1Boby  = 0;
    int player2Body  = 0;
    int player1Head  = 0;
    int player2Head  = 0;
    int player1Wings = 0;
    int player2Wings = 0;
    int player1Legs  = 0;
    int player2Legs  = 0;
    int player1Eyes  = 0;
    int player2Eyes  = 0;
    int player1Tail  = 0;
    int player2Tail  = 0;
    
    int player1BodyCount  = 0;
    int player2BodyCount  = 0;
    int player1HeadCount  = 0;
    int player2HeadCount  = 0;
    int player1WingsCount = 0;
    int player2WingsCount = 0;
    int player1LegsCount  = 0;
    int player2LegsCount  = 0;
    int player1EyesCount  = 0;
    int player2EyesCount  = 0;
    int player1TailCount  = 0;
    int player2TailCount  = 0;
    
    int player1Point = 0;
    int player2Point = 0;
    
    char UserInput;
    
    cout<<"Game Start? (Y/N)";
    cin >>UserInput;
    if (UserInput =='N'||UserInput =='n')
    {
        cout<<"Thank you for playing";
        return -1;
    }
    
    if (UserInput =='Y'||UserInput =='y')
    {
        int Roll1 = rand()%6+1;
        int Roll2 = rand()%6+1;
       
       cout<<"Roll?(Y/N)";
       cin>>UserInput;
       
       if ()
        
        cout<<"Player roll is "<<Roll1;
        cout<<"\nComputer roll is "<<Roll2;
    }else{
        cout<<"Invaild Input";
        return -1;
    }
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호