字符串统计

题目分析:
录入字符串,判断数字有多少个,累加保存。
代码:
#include<iostream>
using namespace std;
int main()
{
char a[100001];
int n;
while (cin >> n&&n)
{
while (n--)
{
getchar();
scanf("%s", a);
int i, num = 0;
int len = strlen(a);
for (i = 0; i < len ; i++)
{
if (a[i] >= '0'&&a[i] <= '9')
{
num++;
}
}
cout << num << endl;
}
}
system("pause");
return 0;
}
来源:https://www.cnblogs.com/pcdl/p/12275377.html