【来源】
《OpenJudge 1.7 字符串基础全解(1-20)》
网址:https://www.codetd.com/article/4120656
【题目】
输入一行字符,统计出其中数字字符的个数。
输入:
一行字符串,总长度不超过255。
输出:
输出为1行,输出字符串里面数字字符的个数。
样例输入:
Peking University is set up at 1898.
样例输出:
4
【代码】
#include<bits/stdc++.h>
using namespace std;
int main ()
{
	char s[255] ;
	gets(s);
	int len = strlen(s);
	int count  = 0;
	for(int i = 0; i < len ;i++)
	{
		if( s[i] - '0' <= 9 &&  s[i] - '0' >= 0 )
		count ++ ;
	}
	cout << count << endl;
	return 0;
}