int main(){
cout<<"*** Welcome to Pickup Sticks ***"<<endl;
string name1, name2, playerTurn;
int sticks, sticksTaken;
char ans;
sticks = 21;
do{
cout<<"Enter name of player 1: ";
cin>>name1;
cout<<"Enter name of player 2: ";
cin>>name2;
cout<<endl;
while(sticks!=0){
cout<<"("<<sticks<<")";
for(int i = 0; i < sticks; i++)
cout<<"|"<<" ";
cout<<endl;
cout<<playerTurn<<"-How many sticks? ";
cin>> sticksTaken;
if((sticksTaken<1)||(sticksTaken>3))
cout<<"Sorry, you must take between 1 and 3 sticks."<<endl;
else{
if(sticks>=3)
sticks-=sticksTaken;
else if(sticks==2){
if(sticksTaken==3)
cout<<"Sorry, only 2 sticks left!"<<endl;
else if(sticksTaken==2)
sticks-=sticksTaken;
cout<<" wins!"<<endl;
else
sticks-=sticksTaken;
cout<<playerTurn<<"wins!"<<endl;
}
else{
if((sticksTaken==3)||(sticksTaken==2))
cout<<"Sorry, only 1 stick left!"<<endl;
else
sticks-=sticksTaken;
cout<<"wins!"<<endl;
break;
}
}
//winning statement
}
cout<<"Play Again? (Y/N)";
cin>>ans;
}while(ans=='y'||ans=='Y');
cout<<endl;
cout<<"*** Thanks for playing Pickup Sticks ***"<<endl;