-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrc.cpp
More file actions
58 lines (55 loc) · 1.07 KB
/
src.cpp
File metadata and controls
58 lines (55 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#define _CRT_SECURE_NO_WARNING
#include<string>
#include<iostream>
#include<malloc.h>
using namespace std;
int main()
{
unsigned int Continumax(char** pOutputstr, char* intputstr);
char *str;
char **p = new char *[128];
str=(char *)malloc(128);
cin.get(str,128,'\n');
p[0]="";
int n=Continumax(p,str);
if(p[0]!="")
cout<<*p<<','<<n<<endl;
else cout<<0<<endl;
return 0;
}
unsigned int Continumax(char** pOutputstr, char* intputstr)
{
////////////////////求字符串内连续最长的数字个数
char *p1=intputstr,*p2,temp[128]={0};
p2=new char[128];
for(int j=0;j<128;j++)
p2[j]=0;
unsigned int n,result=0,con=0;
n=strlen(p1);
if(n<1)
{
p2="";
return 0;
}
for (int i = 0; i <= n; ++i)
{
if (p1[i]>='0'&&p1[i]<='9')
{
temp[con++]=p1[i];
if(result<con)
{
result=con;
for(int k=0;k<con;k++)
p2[k]=temp[k];
}
}
else
{
con=0;
}
}
if(result==0)
p2="";
*pOutputstr=p2;
return result;
}