지금 실컷 줄줄 짜다가.. 중간에 보니깐.... 이 프로그램을 종료 시켜야하는데... 난감하더라고요;;
이거 어찌 꺼야할까요;;
입력을 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;