#include <iostream>
using namespace std;
bool IsDing(int *Pai, int n)
{
int Judge[2][1000]={{-1},{1}};
int *p1,*p2;
int i=0;
int flag=0;
p1=p2=Pai;
do
{
if(*p1==*(p2+1))
{
Judge[1][i]++;
p2=p2+1;
}
else
{
Judge[0][i]=*p1;
p1=p2+1;
i++;
}
}while(p1!=Pai+n);
for(int j=0;j<i;j++)
printf("Judge[0][%d]=%d,Judge[1][%d]=%d,\n",j,Judge[0][j],j,Judge[1][j]);
j=0;
do
{
switch(Judge[1][j])
{
case 1:
if(Judge[0][j]==Judge[0][j+1]-1&&Judge[0][j+1]==Judge[0][j+2]-1
&&Judge[1][j+1]==1)
{
printf("您的派是一副%d,%d,%d顺子.\n",Judge[0][j],Judge[0][j+1],Judge[0][j+2]);
if(Judge[1][j+2]==1)
j=j+3;
else
{
Judge[1][j+2]=Judge[1][j+2]-1;
j=j+2;
}
break;
}
else
{
printf("您的数据有问题!");
getchar();
break;
}
case 2:
printf("您的派是一副%d对子.\n",Judge[0][j]);
j=j+1;
flag++;
break;
case 3:
if(Judge[1][j+1]!=1)
{
printf("您的派是一副%d刻子.\n" , Judge[0][j]);
j=j+1;
break;
}
else if(Judge[1][j+1]==1&&Judge[0][j]==Judge[0][j+1]-1
&&Judge[0][j+1]==Judge[0][j+2]-1)
{
printf("您的派是一副%d对子.\n",Judge[0][j]);
Judge[1][j]=Judge[1][j]-2;
flag++;
break;
}
else
{
printf("您的数据有问题!\n");
getchar();
break;
}
case 4:
if(Judge[1][j+1]!=1)
{
printf("您的派是一副%d杠子.\n" , Judge[0][j]);
j=j+1;
break;
}
else if(Judge[1][j+1]==1&&Judge[0][j]==Judge[0][j+1]-1
&&Judge[0][j+1]==Judge[0][j+2]-1)
{
printf("您的派是一副%d刻子.\n",Judge[0][j]);
Judge[1][j]=Judge[1][j]-3;
break;
}
else
{
printf("您的数据有问题!\n");
getchar();
break;
}
}
}while(j<i);
return flag;
}
int main(void)
{
//例如这里要判断9,9这个组合是否存在
int cpg[] = {1,1,1,2,3,3,3,3,4,5,9,9,9}; //不仅仅是这些,还可以任意组合
if (IsDing(cpg, sizeof(cpg)/sizeof(int)))
cout << "有" << endl;
else
cout << "没有" << endl;
return 1;
}