题目描述

读入一个字符串str,输出字符串str中的连续最长的数字串

#include<iostream>
#include<string>
using namespace std;
int main()
{
  string str,cur,ret;
    cin >> str;
    for(int i = 0; i<= str.length();i++)
    {
        if(str[i] >= '0' && str[i] <= '9')
            cur += str[i];
        else
        {
             if(ret.length()< cur.length())
            ret = cur;
            else
                cur.clear();
        }
    }
    cout << ret <<endl;
}