感觉判断没有错,但每次执行就不行,要么一直输出不是对子,要么一直出牌,到底是哪里出了错??
void unlimit(int n,List<string> &whichPai,List<string> &stack)
{
string str="";
string storePai[16]={};
int m=n;
int i=0,j=0;
cout<<"要出的牌:"<<endl;
//存牌
while(m>0)
{
cin>>str;
storePai[i++]=str;
m--;
}
//出多张牌
switch(n)
{
case 2:
if(storePai[0][3]==storePai[1][3])
{
while(storePai[j]!="")
{
whichPai.remove(whichPai.find(storePai[j]));
stack.insertAsLast(storePai[j]);
j++;
}
}
else
cout<<"不是对子!"<<endl;
break;
case 4:
if(storePai[0][3]==storePai[1][3]==storePai[2][3]==storePai[3][3])
{
while(storePai[j]!="")
{
whichPai.remove(whichPai.find(storePai[j]));
stack.insertAsLast(storePai[j]);
j++;
}
}
else
cout<<"不是炸弹!"<<endl;
break;
}
}