字符串中最长的数字子串

给定 一个字符串,找出其中最长的数字子串,例如:

输入:“asdf12hh1234hdhf145624d”

输出:6

            145624


#include 
#include 

using namespace std;
int find_longest(const char* str,char* num,int size)
{
    int i,j;
    int num_count,count;
    int max_count = 0;
    for(i=0;i max_count)
        {
            max_count = num_count;
            count = i;
        }
    }
    j = 0;
    for(i=(count-max_count+1);i<=count;i++)
    {
        *(num+j) = *(str+i);
        j++;
    }
    *(num+j) = '\0';
    return max_count;
}
int main()
{
    string s;
    cin>>s;
    const char* str = s.c_str();
    int size = s.length();
    char* num = new char[size];
    int num_count = find_longest(str,num,size);
    cout<


你可能感兴趣的:(算法)