如何将足彩的复式投注进行中奖匹配,如将复式投注310,310,310,1,1,0,0,3,1,10,10,30,30,1跟中奖号码3,1,1,1,1,0,0,3,1,1,1,3,0,1进行匹配,算出其中的一二三等奖的个数
目前想到的思路是先将复式投注转换为单式投注,但是,这个转换的算法,还没找到!希望能得到高人的指点!

解决方案 »

  1.   

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>char str[] = "310,310,310,1,1,0,0,3,1,10,10,30,30,1";char strResult[255] = {0};int n = 0;void Test(const char *pStr, int num)
    {
        int len = 0;    char *p = strstr(pStr, ",");
        if (p != NULL) { // Find ','
            len = p - pStr;
        }
        else {           // The last numbers
            len = strlen(pStr);
        }    for (int i=0; i<len; i++) {        strResult[num] = pStr[i];        // Print the string you need
            if (NULL == p) {
                printf("Result:%d \t %s\n", ++n, strResult);
                system("pause");
            }
            else {
                Test(p + 1, num + 1);
            }
        }
        
        num++;
    }int main()
    {
        Test(str, 0);    return 0;
    }