#include <stdio.h>
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <math.h>
using namespace std;
void outhanshu(char *str,int end,int max){
for(int j=end-max+1;j<=end;j++){
cout<<str[j];
}
}
int main(){
char str[1005];
while(cin.getline(str,1000)){
int length=strlen(str);
int count=0;
int max=0;
int end=-1;
for(int i=0;i<length;i++){
if(str[i]<='9'&&str[i]>='0'){
count++;
if(max<count){
max=count;
end=i;
}
}
else{
count=0;
}
}
if(max==0){
cout<<"";
}
else{
int count1=0;
int end1=-1;
for(int i=0;i<length;i++){
if(str[i]<='9'&&str[i]>='0'){
count1++;
if(max==count1){
end1=i;
outhanshu(str,end1,max);
}
}
else{
count1=0;
}
}
cout<<',';
cout<<max<<endl;
}
}
return 0;}
字符串求数字长度
最新推荐文章于 2023-03-27 07:28:18 发布