게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
c++ 가위바위보게임인데요... 이거 어떻게 꺼야할까요;;;
게시물ID : freeboard_420958짧은주소 복사하기
작성자 : 시럽
추천 : 1
조회수 : 1284회
댓글수 : 9개
등록시간 : 2010/05/14 00:46:28
지금 실컷 줄줄 짜다가..
중간에 보니깐.... 이 프로그램을 종료 시켜야하는데... 난감하더라고요;;

이거 어찌 꺼야할까요;;

입력을 0을 받으면 종료시켜야하는데...
while문에서 0이 나올떄까지 계속 실행시켜야할텐데...
그렇다고 0이 나오면 출력할 문장은 또 출력해야하고;;
난감해서 헬프 부탁드립니다 ㅠ
--------------------------------------------------------------------------------------------

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

class G_Computer{
int com;
public:
void Getcom(){
srand( (unsigned)time(NULL) );
com = rand() % 3+1;
}
void Show(){
switch(com)
{
case 1:
cout<<"컴퓨터 : 가위"<<endl;
break;
case 2:
cout<<"컴퓨터 : 바위"<<endl;
break;
case 3:
cout<<"컴퓨터 : 보"<<endl;
break;
}
}
int Return_com(){
return com;
}
};

class C_User{
int user;
public:
void Getuser(){
cout<<"가위<1>, 바위<2>, 보<3>, 종료<0> :";
cin>>user;

while(user>3 || user<0){
cout<<"\n\n";
cout<<"잘못 입력하셨습니다... 다시 입력해주세요..."<<endl;
cout<<"가위<1>, 바위<2>, 보<3>, 종료<0> :";
cin>>user;
}
}
void Show(){
switch(user)
{
case 0:
cout<<"프로그램을 종료합니다"<<endl;
cout<<"아무키나 눌러주세요...."<<endl;
break;
case 1:
cout<<"사용자 : 가위"<<endl;
break;
case 2:
cout<<"사용자 : 바위"<<endl;
break;
case 3:
cout<<"사용자 : 보"<<endl;
break;
}

}
int Return_user(){
return user;
}
};

class GBB{
int com, user, dap;
public:
GBB(){
ShowTitle();
play();
}
void ShowTitle(){
cout<<"#################"<<endl;
cout<<"가위 바위 보 게임"<<endl;
cout<<"#################"<<endl;
cout<<endl;
}
void play(){
G_Computer Computer;
C_User User;

while(1){
Computer.Getcom();
User.Getuser();
Computer.Show();
User.Show();

dap = Computer.Return_com() - User.Return_user();
if(dap==0)
cout<<"비겼습니다."<<endl;
else if(dap>0)
cout<<"졌습니다."<<endl;
else
cout<<"이겼습니다."<<endl;
}
}
};

void main(void)
{
GBB a;
}
전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호