链接:https://www.nowcoder.com/questionTerminal/bd891093881d4ddf9e56e7cc8416562d
来源:牛客网
读入一个字符串str,输出字符串str中的连续最长的数字串
#include <bits/stdc++.h>
using namespace std;
int main(){
string str;
cin>>str;
int count=0,max=0,end=0;
for (int i=0;str[i]!='\0';i++){
if((int)str[i]<58&&(int)str[i]>47){
count++;
if(count>max){
max=count;
end=i;
}
}
else count=0;
}
for(int i=end-max+1;i<=end;i++){
cout<<str[i];
}
cout<<endl;
}