import re while True: try: s=input() #t = re.compile(r'\d+') a=re.findall('\d+',s)#用正则表达式匹配出字符串中的数字,注意import re不可少 length=0 res=[] for i in a: if len(i)>length: length=len(i) res=[] res.append(i) elif len(i)==length: res.append(i) st=res[0] for s in res[1:]: st=st+s print(st+','+str(length)) except: break
#include <iostream> #include <string> using namespace std; int main(){ string s; while(cin >> s){ int max=0; string temp; string res; for(int i=0;i<s.size();i++){ if(s[i] >= '0' && s[i] <= '9'){ temp+=s[i]; while(s[i+1] >= '0' && s[i+1] <= '9'){ i++; temp+=s[i]; } if(temp.size()>max){ max=temp.size(); res=temp; } else if(temp.size()==max){ res+=temp; } } temp.clear(); } cout << res << ',' << max <<endl; } return 0; }