题解 | #字符串中找出连续最长的数字串#
字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/bd891093881d4ddf9e56e7cc8416562d
#include <iostream> using namespace std; #include<string> int main() { string str; string cur; string ret; cin>>str; int i=0; while(i<=str.size()) { if('0'<=str[i]&&str[i]<='9') { cur+=str[i]; } else { if(cur.size()>ret.size()) { ret=cur; cur.clear(); } else { cur.clear(); } } i++; } cout<<ret<<endl; return 0; }#悬赏#