c语言输入一串字符统计个数 C语言编写函数,统计字符串中数字字符的个数?
C语言编写函数,统计字符串中数字字符的个数?#包括和限制。H>#包含<string。H>main(){int i,j=0,K char a[1000]//根据实际情况自行调整长度。Prin
C语言编写函数,统计字符串中数字字符的个数?
#包括和限制。H>#包含<string。H>main(){int i,j=0,K char a[1000]//根据实际情况自行调整长度。Printf(“请输入字符串:n”)获取(a)k=strlen(a)for(I=0I<ki)if(“0”<=a[I]<=“9”)J Printf(“此字符串中有%d个数字字符!n“,j)}
#include
#include
int countdigit(char*p)
{int n=0
for(*pp)
if(isdigit(*p))n
return n
}
int main()
{char s[300
]printf(“请输入字符串:n”)
get(s)
printf(“字符串中有%d个数字。n”,countdigit(s))
return 0
}