牛客网链接:
https://www.nowcoder.com/questionTerminal/bd891093881d4ddf9e56e7cc8416562d
题目描述:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string str;
cin>>str;
string maxstr;
int maxlegth = 0;
string tmp;
for (string::size_type ix = 0; ix < str.length(); ++ix)
{
if ((str[ix] >= '0') || (str[ix] <= '9'))
{
while((str[ix] >= '0') && (str[ix] <= '9'))
{
tmp += str[ix++];
}
if (tmp.size() > maxlegth)
{
maxstr = tmp;
maxlegth = tmp.size();
}
}
tmp.clear();
}
cout<<maxstr;
return 0;
}