- 题目:在一个字符串中找出 数字串的个数!
如 "sadf234lkji8999lkwekj80"; 则输出 3!
int FindNum( cosnt char * str ); - #include <stdio.h>
#include <ctype.h>
int FindNum (const char *str)
{
int i = 0;
while (*str != '\0')
{
if (isdigit(*str))
{
i++;
str++;
while (*str != '\0' && isdigit(*str))
{
str++;
}
}
else
{
str++;
}
}
return i;
}
int main()
{
char p[100];
printf("Please input your string:\n");
gets(p);
int i = FindNum(p);
printf("result:%d\n",i);
return 0;
}希望多提意见!
评论