字符串统计

#include <cstring>
#include <string>
#include <iostream>
using namespace std;

int main()
{
	int n, len;
	string str;
	cin >> n;
	while(n --)
	{
		int num = 0;
		cin >> str;
		len = str.length();
		
		for(int i = 0; i < len; ++ i)
		{
			if(str[i] >= '0' && str[i] <= '9')	num ++;	
		}
		cout << num << endl;
	}
	
	return 0;
}

  

posted @ 2019-07-29 10:53  青衫客36  阅读(87)  评论(0编辑  收藏  举报