//输入一个字符串,内有数字和非数字字符,例如:
//jh2515da555adad22 dsd55252aa
//将其中连续数字作为一个整数,依次存放在,一组数a中,
//例如,2515放在a[0],555放在a[1],,,,,,
//统计有多少个整数,并输出这些数。
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
int count=0;//统计整数个数
int Findnumbers(const char *str,int *des)
{
assert(str!=NULL&&des!=NULL);
int n;
int i=0;
int tmp=0;//jh2515da555adad22 dsd55252aa
do//使用do while防止出现bug(最后一位是数字的情况)
{
if(isdigit(*str))//数字
{
n=(str)-‘0’;
tmp=tmp10+n;
i=1;
}
else
{
if(i==1)
{
*des=tmp;
des++;
count++;
i=0;
tmp=0;
}
}
str++;
}while((*str)!=’\0’);
return count;
}
int main()
{
int n;
int i;
const char arr[]=“jh2515da555adad22 dsd55252

最低0.47元/天 解锁文章
2530

被折叠的 条评论
为什么被折叠?



