标签:hdu
2 asdfasdf123123asdfasdf asdf111111111asdfasdfasdf
6 9
#include <iostream> #include <cstring> #include <stdlib.h> using namespace std; int main() { char c[100000]; int num = 0; memset(c,0,100000); int n; while (cin >> n) { while (n--) { cin >> c; num = 0; int p= strlen(c); for (int i=0; i<p; i++) { if (c[i] >= '0' && c[i] <= '9') num++; } cout << num << endl; } } return 0; }
#include<iostream> #include<string> using namespace std; int main() { string str; int n; cin>>n; while(n --) { int count = 0; int len; cin>>str; len = str.size(); for(int i = 0;i < len;i++) { if(str.at(i) >= '0' && str.at(i) <= '9') { count++; } } cout<<count<<endl; } return 0; }
标签:hdu
原文地址:http://blog.csdn.net/xiaotan1314/article/details/45972735