题目51 字符串中包含的最长的非严格递增连续数字序列长度(ok)

输入一个字符串仅包含大小写字母和数字
求字符串中包含的最长的非严格递增连续数字序列长度
比如:
    12234属于非严格递增数字序列
示例:
输入
    abc2234019A334bc
输出
    4
说明:
    2234为最长的非严格递增连续数字序列,所以长度为4

    aaaaaa44ko543j123j7345677781
    aaaaa34567778a44ko543j123j71
    345678a44ko543j123j7134567778aa

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define MAX_LEN 1000
int IsSame(char *s, int begin, int end)
{
    for (int i = begin; i < end; i++) {
        if (s[i] != s[i + 1]) {
            return -1;
        }
    }

    return 1;
}


int GetMaxLen(char *s)
{
    int len = strlen(s);
    int i, count = 1, max = 0, begin = 0;
    char tmp[64] = {0};

    for (i = 0; i < len - 1; i++) {
        if ((s[i] + 1 == s[i + 1]) || (s[i] == s[i + 1])) {
            count++;
        } else {
            if (IsSame(s, begin, i) == 1) {
                count = 1;
            }
            if (max < count) {
                max = count;
            }
            begin = i + 1;
            count = 1;
        }
    }

    if (max < count) {
        max = count;
    }
    printf("count=%d\n", max);
}

int main()
{
    char s[MAX_LEN] = {0};

    gets(s);

    GetMaxLen(s);
}