百词斩2018春招第一题

#include <bits/stdc++.h>
using namespace std;
/*
在一大串数字和字符中,输出最大的数字串
样例:
输入:helloworld123heilllljsahkjfha1456872
输出:1456872
*/
int main()
{
long max = 0;
string s;
string str; cin >> str;
for (int i = 0; i < str.length();){
while (str[i] >= '0' && str[i] <= '9')
{
s += str[i++];
}
if (s.size()>1 && atoi(s.c_str())>max) max = atoi(s.c_str()), s.clear();
++i;
}
cout << max << endl;

return 0;
}

原文地址:https://www.cnblogs.com/beihaidao/p/8643904.html