扑克排序

#include <iostream>
#include <stdio.h>
using namespace std;
int IsPairFive(int *number,int length)
{
    if(number==NULL||length<1)
        return 0;
    int flag[14]={0};
    int NumZero=0;
    int numOther=0;
    for(int i=0;i<5;i++)
    {
        flag[number[i]]++;
        if(flag[number[i]]>1&&number[i]>0)return 0;
    }
    int k=1;
    while(flag[k]==0)
        k++;
    printf("%d\n",k);
    int cont=k+5;
    for(;k<=13&&k<cont;k++)
    {
        if(flag[k]==0)
            NumZero++;
        else
            if(flag[k]==1)
            numOther++;
    }
    printf("%d %d %d\n",numOther,flag[0],NumZero);
    if(NumZero<=flag[0]&&numOther+flag[0]==5)
    return 1;
    return 0;
}
int main()
{
    int *number={0};
    if(IsPairFive(number,5)==1)
    {
        printf("YES\n");
    }
    else
        printf("NO\n");
    return 0;
}

posted on 2014-06-20 19:02  XiaoFei Wang  阅读(183)  评论(0编辑  收藏  举报

导航