题目描述
输入一行字符串(可能包含空格),统计出其中数字字符的个数。
输入
一行字符串,总长度不超过255。
输出
输出字符串中数字字符的个数。
样例输入 Copy
At present, there are more than 20,000 full-time students at ZWU, with a staff of more than 1,000.
样例输出 Copy
9
#include <stdio.h>
#include <string.h>
int main(){
int i = 0,n = 0;
char str1[300];
gets(str1);
while(str1[i] != '\0'){
if(str1[i] >= '0'&&str1[i] <= '9')
n++;
i++;
}
printf("%d",n);
return 0;
}