题目:
示例
代码实现
#include<iostream>
#include<string>
using namespace std;
char * GetMaxCount(char *str,size_t size)
{
if (size == 0)
return NULL;
int count = 0;
int max = 0;
size_t i = 0;
char *cur = str;
char *start = NULL;
char *ret = start;
size_t j = 0;
while (i < size)
{
start = cur;
while (i < size && *cur >= '0' && *cur <= '9')
{
count++;
cur++;
i++;
}
if (i <= size)
{
if (count > max)
{
max = count;
j = i;
ret = start;
str[j] = '\0';
}
cur++;
i++;
count = 0;
}
}
return ret;
}
int main()
{
string str;
getline(cin, str);
char *ret = GetMaxCount((char*)str.c_str(),str.size());
cout << ret;
return 0;
}